Import GDB 9.2

This commit is contained in:
Les De Ridder 2020-06-18 10:11:10 +02:00
commit ce75aa9c80
12673 changed files with 6120636 additions and 0 deletions

340
COPYING Normal file
View 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
COPYING.LIB Normal file
View 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
COPYING3 Normal file
View 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
COPYING3.LIB Normal file
View 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.

16108
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

118
MAINTAINERS Normal file
View File

@ -0,0 +1,118 @@
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@sourceware.org
gdb-patches@sourceware.org
bfd/; binutils/; elfcpp/; gas/; gold/; gprof/; ld/; opcodes/; cpu/;
libctf/; BFD's and libctf's parts of include/
binutils: http://sourceware.org/binutils/
Patches to binutils@sourceware.org.
Please notify the following of any interface changes:
gdb-patches@sourceware.org
cgen/; cgen parts of opcodes/, sim/ & include/
cgen: http://sourceware.org/cgen/
Patches to cgen@sourceware.org
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@sourceware.org
gdb-patches@sourceware.org
depcomp; mkinstalldirs
Send bug reports and patches to bug-automake@gnu.org.
gdb/; gnulib/; readline/; sim/; GDB's part of include/
GDB: http://www.gnu.org/software/gdb/
Patches to gdb-patches@sourceware.org.
See also gdb/MAINTAINERS and sim/MAINTAINERS.
include/
The rule is that if the file exists in the gcc tree
then gcc owns it. Thus you have to look at the gcc tree
to know whether any particular file is owned by gcc.
See also binutils/, gdb/, sid/, gcc/, libiberty/ etc.
intl/; config.rhost; libiberty/; libiberty's part of include/;
compile; depcomp; install-sh; missing; ylwrap; config/
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.
move-if-change
Send bug reports and patches to bug-gnulib@gnu.org.
symlink-tree
gcc: http://gcc.gnu.org
See libiberty.
newlib/; libgloss/
http://sourceware.org/newlib/
Patches to newlib@sourceware.org.
sid/; SID's part of cgen/
sid: http://sourceware.org/sid/
Patches to sid@sourceware.org
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://sourceware.org/insight/
Contact insight@sourceware.org.
winsup/
cygwin: http://sourceware.org/cygwin
Patches to cygwin-patches@cygwin.com.
General discussion cygwin@cygwin.com.
config-ml.in; makefile.vms; mkdep; setup.com;
etc/; utils/;
Any global maintainer can approve changes to these
files and directories.
modules file
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: */

640
Makefile.def Normal file
View File

@ -0,0 +1,640 @@
#! /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-2017 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 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; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// "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= flex; };
build_modules= { module= m4; };
build_modules= { module= texinfo; };
build_modules= { module= fixincludes; };
build_modules= { module= libcpp;
extra_configure_flags='--disable-nls am_cv_func_iconv=no';};
host_modules= { module= bfd; bootstrap=true; };
host_modules= { module= opcodes; bootstrap=true; };
host_modules= { module= binutils; bootstrap=true; };
host_modules= { module= bison; no_check_cross= true; };
host_modules= { module= cgen; };
host_modules= { module= dejagnu; };
host_modules= { module= etc; };
host_modules= { module= fastjar; no_check_cross= true; };
host_modules= { module= fixincludes; bootstrap=true;
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= gmp; lib_path=.libs; bootstrap=true;
// Work around in-tree gmp configure bug with missing flex.
extra_configure_flags='--disable-shared LEX="touch lex.yy.c"';
extra_make_flags='AM_CFLAGS="-DNO_ASM"';
no_install= true;
// none-*-* disables asm optimizations, bootstrap-testing
// the compiler more thoroughly.
host="none-${host_vendor}-${host_os}";
// gmp's configure will complain if given anything
// different from host for target.
target="none-${host_vendor}-${host_os}"; };
host_modules= { module= mpfr; lib_path=src/.libs; bootstrap=true;
extra_configure_flags='--disable-shared @extra_mpfr_configure_flags@';
extra_make_flags='AM_CFLAGS="-DNO_ASM"';
no_install= true; };
host_modules= { module= mpc; lib_path=src/.libs; bootstrap=true;
extra_configure_flags='--disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@';
no_install= true; };
host_modules= { module= isl; lib_path=.libs; bootstrap=true;
extra_configure_flags='--disable-shared @extra_isl_gmp_configure_flags@';
extra_make_flags='V=1';
no_install= true; };
host_modules= { module= libelf; lib_path=.libs; bootstrap=true;
extra_configure_flags='--disable-shared';
no_install= true; };
host_modules= { module= gold; bootstrap=true; };
host_modules= { module= gprof; };
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= libbacktrace; bootstrap=true; };
host_modules= { module= libcpp; bootstrap=true; };
host_modules= { module= libdecnumber; bootstrap=true; };
host_modules= { module= libgui; };
host_modules= { module= libiberty; bootstrap=true;
extra_configure_flags='@extra_host_libiberty_configure_flags@';};
// Linker plugins may need their own build of libiberty; see
// gcc/doc/install.texi. We take care that this build of libiberty doesn't get
// installed. It's a helper library for linker plugins, so we pay attention to
// @extra_linker_plugin_flags@ and @extra_linker_plugin_configure_flags@.
host_modules= { module= libiberty-linker-plugin; bootstrap=true;
module_srcdir=libiberty;
extra_configure_flags='@extra_host_libiberty_configure_flags@ --disable-install-libiberty @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
extra_make_flags='@extra_linker_plugin_flags@'; };
// We abuse missing to avoid installing anything for libiconv.
host_modules= { module= libiconv;
bootstrap=true;
extra_configure_flags='--disable-shared';
no_install= true;
missing= pdf;
missing= html;
missing= info;
missing= install-pdf;
missing= install-html;
missing= install-info; };
host_modules= { module= m4; };
host_modules= { module= readline; };
host_modules= { module= sid; };
host_modules= { module= sim; };
host_modules= { module= texinfo; no_install= true; };
host_modules= { module= zlib; no_install=true; no_check=true;
bootstrap=true;
extra_configure_flags='@extra_host_zlib_configure_flags@';};
host_modules= { module= gnulib; };
host_modules= { module= gdb; };
host_modules= { module= expect; };
host_modules= { module= guile; };
host_modules= { module= tk; };
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; };
host_modules= { module= lto-plugin; bootstrap=true;
extra_configure_flags='--enable-shared @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
extra_make_flags='@extra_linker_plugin_flags@'; };
host_modules= { module= libcc1; extra_configure_flags=--enable-shared; };
host_modules= { module= gotools; };
host_modules= { module= libctf; no_check=true;
bootstrap=true; };
target_modules = { module= libstdc++-v3;
bootstrap=true;
lib_path=src/.libs;
raw_cxx=true; };
target_modules = { module= libsanitizer;
bootstrap=true;
lib_path=.libs;
raw_cxx=true; };
target_modules = { module= libmpx;
bootstrap=true;
lib_path=.libs; };
target_modules = { module= libvtv;
bootstrap=true;
lib_path=.libs;
raw_cxx=true; };
target_modules = { module= libcilkrts;
lib_path=.libs; };
target_modules = { module= liboffloadmic;
lib_path=.libs;
extra_configure_flags='@extra_liboffloadmic_configure_flags@'; };
target_modules = { module= libssp; lib_path=.libs; };
target_modules = { module= newlib; };
target_modules = { module= libgcc; bootstrap=true; no_check=true; };
target_modules = { module= libbacktrace; };
target_modules = { module= libquadmath; };
target_modules = { module= libgfortran; };
target_modules = { module= libobjc; };
target_modules = { module= libgo; };
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= libffi; no_install=true; };
target_modules = { module= zlib; };
target_modules = { module= rda; };
target_modules = { module= libada; };
target_modules = { module= libgomp; bootstrap= true; lib_path=.libs; };
target_modules = { module= libitm; lib_path=.libs; };
target_modules = { module= libatomic; 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= AWK ; };
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= SED ; };
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_CHECKING ; };
flags_to_pass = { flag= STAGE1_LANGUAGES ; };
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= CXXFLAGS_FOR_TARGET ; };
flags_to_pass = { flag= DLLTOOL_FOR_TARGET ; };
flags_to_pass = { flag= FLAGS_FOR_TARGET ; };
flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; };
flags_to_pass = { flag= GOC_FOR_TARGET ; };
flags_to_pass = { flag= GOCFLAGS_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= OBJCOPY_FOR_TARGET ; };
flags_to_pass = { flag= RANLIB_FOR_TARGET ; };
flags_to_pass = { flag= READELF_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= BUILD_CONFIG ; };
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-flex; on=all-build-texinfo; };
dependencies = { module=all-build-flex; on=all-build-bison; };
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; };
dependencies = { module=all-build-libcpp; on=all-build-libiberty; };
// Host modules specific to gcc.
dependencies = { module=configure-gcc; on=configure-intl; };
dependencies = { module=configure-gcc; on=all-gmp; };
dependencies = { module=configure-gcc; on=all-mpfr; };
dependencies = { module=configure-gcc; on=all-mpc; };
dependencies = { module=configure-gcc; on=all-isl; };
dependencies = { module=configure-gcc; on=all-lto-plugin; };
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=configure-gcc; on=all-libelf; };
dependencies = { module=configure-gcc; on=all-libiconv; };
dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
dependencies = { module=all-gcc; on=all-intl; };
dependencies = { module=all-gcc; on=all-mpfr; };
dependencies = { module=all-gcc; on=all-mpc; };
dependencies = { module=all-gcc; on=all-isl; };
dependencies = { module=all-gcc; on=all-build-texinfo; };
dependencies = { module=all-gcc; on=all-build-bison; };
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-build-libcpp; };
dependencies = { module=all-gcc; on=all-zlib; };
dependencies = { module=all-gcc; on=all-libbacktrace; hard=true; };
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=all-gcc; on=all-lto-plugin; };
dependencies = { module=all-gcc; on=all-libiconv; };
dependencies = { module=info-gcc; on=all-build-libiberty; };
dependencies = { module=dvi-gcc; on=all-build-libiberty; };
dependencies = { module=pdf-gcc; on=all-build-libiberty; };
dependencies = { module=html-gcc; on=all-build-libiberty; };
dependencies = { module=install-gcc ; on=install-fixincludes; };
dependencies = { module=install-gcc ; on=install-lto-plugin; };
dependencies = { module=install-strip-gcc ; on=install-strip-fixincludes; };
dependencies = { module=install-strip-gcc ; on=install-strip-lto-plugin; };
dependencies = { module=configure-libcpp; on=configure-libiberty; hard=true; };
dependencies = { module=configure-libcpp; on=configure-intl; };
dependencies = { module=configure-libcpp; on=all-libiconv; };
dependencies = { module=all-libcpp; on=all-libiberty; hard=true; };
dependencies = { module=all-libcpp; on=all-intl; };
dependencies = { module=all-libcpp; on=all-libiconv; };
dependencies = { module=all-fixincludes; on=all-libiberty; };
dependencies = { module=all-gnattools; on=all-target-libada; };
dependencies = { module=all-gnattools; on=all-target-libstdc++-v3; };
// Depending on the specific configuration, the LTO plugin will either use the
// generic libiberty build or the specific build for linker plugins.
dependencies = { module=all-lto-plugin; on=all-libiberty; };
dependencies = { module=all-lto-plugin; on=all-libiberty-linker-plugin; };
dependencies = { module=configure-libcc1; on=configure-gcc; };
dependencies = { module=all-libcc1; on=all-gcc; };
dependencies = { module=all-gotools; on=all-target-libgo; };
dependencies = { module=all-utils; on=all-libiberty; };
dependencies = { module=configure-intl; on=all-libiconv; };
dependencies = { module=configure-mpfr; on=all-gmp; };
dependencies = { module=configure-mpc; on=all-mpfr; };
dependencies = { module=configure-isl; on=all-gmp; };
dependencies = { module=all-intl; on=all-libiconv; };
// 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=configure-gdb; on=all-gnulib; };
// Depend on all-libiconv so that configure checks for iconv
// functions will work.
dependencies = { module=configure-gdb; on=all-libiconv; };
dependencies = { module=all-gdb; on=all-libiberty; };
dependencies = { module=all-gdb; on=all-libiconv; };
dependencies = { module=all-gdb; on=all-gnulib; };
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-sim; };
dependencies = { module=all-gdb; on=all-libdecnumber; };
dependencies = { module=all-gdb; on=all-libtermcap; };
dependencies = { module=all-gdb; on=all-libctf; };
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=all-bfd; on=all-zlib; };
dependencies = { module=configure-opcodes; on=configure-libiberty; hard=true; };
dependencies = { module=all-opcodes; on=all-libiberty; };
// We must build gas before binutils, gprof, ld and gold to avoid race
// condition in the prev-gcc/as script during bootstrap of combined tree
// with GCC and binutils. See PR gas/14899 for details.
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-intl; };
dependencies = { module=all-binutils; on=all-gas; };
dependencies = { module=all-binutils; on=all-libctf; };
dependencies = { module=all-ld; on=all-libctf; };
// 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; };
dependencies = { module=install-strip-binutils; on=install-strip-opcodes; };
// libopcodes depends on libbfd
dependencies = { module=install-opcodes; on=install-bfd; };
dependencies = { module=install-strip-opcodes; on=install-strip-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=all-gprof; on=all-gas; };
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-flex; };
dependencies = { module=all-ld; on=all-intl; };
dependencies = { module=all-ld; on=all-gas; };
dependencies = { module=all-ld; on=all-binutils; };
dependencies = { module=install-ld; on=install-gold; };
dependencies = { module=install-strip-ld; on=install-strip-gold; };
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-gas; };
dependencies = { module=check-gold; on=all-binutils; };
dependencies = { module=check-gold; on=all-gas; };
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=install-strip-itcl; on=install-strip-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-strip-sid; on=install-strip-tcl; };
dependencies = { module=install-sid; on=install-tk; };
dependencies = { module=install-strip-sid; on=install-strip-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; };
dependencies = { module=all-libctf; on=all-libiberty; hard=true; };
dependencies = { module=all-libctf; on=all-bfd; };
dependencies = { module=all-libctf; on=all-zlib; };
// So that checking for ELF support in BFD from libctf configure is possible.
dependencies = { module=configure-libctf; on=all-bfd; };
dependencies = { module=configure-libctf; on=all-intl; };
dependencies = { module=configure-libctf; on=all-zlib; };
dependencies = { module=configure-libctf; on=all-libiconv; };
// Warning, these are not well tested.
dependencies = { module=all-bison; on=all-intl; };
dependencies = { module=all-bison; on=all-build-texinfo; };
dependencies = { module=all-flex; on=all-build-bison; };
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-m4; on=all-intl; };
dependencies = { module=all-m4; 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=libitm; cxx=true; };
lang_env_dependencies = { module=libffi; cxx=true; };
lang_env_dependencies = { module=libcilkrts; cxx=true; };
lang_env_dependencies = { module=liboffloadmic; 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-fastjar; on=configure-target-zlib; };
dependencies = { module=all-target-fastjar; on=all-target-zlib; };
dependencies = { module=configure-target-libgo; on=configure-target-libffi; };
dependencies = { module=configure-target-libgo; on=all-target-libstdc++-v3; };
dependencies = { module=all-target-libgo; on=all-target-libbacktrace; };
dependencies = { module=all-target-libgo; on=all-target-libffi; };
dependencies = { module=all-target-libgo; on=all-target-libatomic; };
dependencies = { module=configure-target-libstdc++-v3; on=configure-target-libgomp; };
dependencies = { module=configure-target-liboffloadmic; on=configure-target-libgomp; };
dependencies = { module=configure-target-libsanitizer; on=all-target-libstdc++-v3; };
dependencies = { module=configure-target-libvtv; on=all-target-libstdc++-v3; };
// parallel_list.o and parallel_settings.o depend on omp.h, which is
// generated by the libgomp configure. Unfortunately, due to the use of
// recursive make, we can't be that specific.
dependencies = { module=all-target-libstdc++-v3; on=configure-target-libgomp; };
dependencies = { module=all-target-liboffloadmic; on=all-target-libgomp; };
dependencies = { module=install-target-libgo; on=install-target-libatomic; };
dependencies = { module=install-target-libgfortran; on=install-target-libquadmath; };
dependencies = { module=install-target-libgfortran; on=install-target-libgcc; };
dependencies = { module=install-target-libsanitizer; on=install-target-libstdc++-v3; };
dependencies = { module=install-target-libsanitizer; on=install-target-libgcc; };
dependencies = { module=install-target-libvtv; on=install-target-libstdc++-v3; };
dependencies = { module=install-target-libvtv; on=install-target-libgcc; };
dependencies = { module=install-target-libcilkrts; on=install-target-libstdc++-v3; };
dependencies = { module=install-target-libcilkrts; on=install-target-libgcc; };
dependencies = { module=install-target-liboffloadmic; on=install-target-libstdc++-v3; };
dependencies = { module=install-target-liboffloadmic; on=install-target-libgcc; };
dependencies = { module=install-target-libitm; on=install-target-libgcc; };
dependencies = { module=install-target-libobjc; on=install-target-libgcc; };
dependencies = { module=install-target-libstdc++-v3; on=install-target-libgcc; };
// Target modules in the 'src' repository.
lang_env_dependencies = { module=libtermcap; };
lang_env_dependencies = { module=rda; };
lang_env_dependencies = { module=winsup; };
dependencies = { module=all-target-libgloss; on=all-target-newlib; };
dependencies = { module=all-target-winsup; on=all-target-libtermcap; };
dependencies = { module=configure-target-newlib; on=all-binutils; };
dependencies = { module=configure-target-newlib; on=all-ld; };
dependencies = { module=configure-target-libgfortran; on=all-target-libquadmath; };
dependencies = { module=configure-target-libgfortran; on=all-target-libbacktrace; };
languages = { language=c; gcc-check-target=check-gcc; };
languages = { language=c++; gcc-check-target=check-c++;
lib-check-target=check-target-libstdc++-v3;
lib-check-target=check-target-libitm-c++;
lib-check-target=check-target-libgomp-c++; };
languages = { language=fortran; gcc-check-target=check-fortran;
lib-check-target=check-target-libquadmath;
lib-check-target=check-target-libgfortran;
lib-check-target=check-target-libgomp-fortran; };
languages = { language=ada; gcc-check-target=check-ada;
lib-check-target=check-target-libada; };
languages = { language=objc; gcc-check-target=check-objc;
lib-check-target=check-target-libobjc; };
languages = { language=obj-c++; gcc-check-target=check-obj-c++; };
languages = { language=go; gcc-check-target=check-go;
lib-check-target=check-target-libgo; };
// Toplevel bootstrap
bootstrap_stage = { id=1 ; };
bootstrap_stage = {
id=2 ; prev=1 ;
bootstrap_target=bootstrap2 ; };
bootstrap_stage = {
id=3 ; prev=2 ; lean=1 ;
compare_target=compare ;
bootstrap_target=bootstrap ;
cleanstrap_target=cleanstrap ; };
bootstrap_stage = {
id=4 ; prev=3 ; lean=2 ;
compare_target=compare3 ;
bootstrap_target=bootstrap4 ; };
bootstrap_stage = {
id=profile ; prev=1 ; };
bootstrap_stage = {
id=feedback ; prev=profile ;
bootstrap_target=profiledbootstrap ; };

51714
Makefile.in Normal file

File diff suppressed because it is too large Load Diff

1982
Makefile.tpl Normal file

File diff suppressed because it is too large Load Diff

47
README Normal file
View 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.

25
README-maintainer-mode Normal file
View File

@ -0,0 +1,25 @@
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 the respective upstream directories:
ftp://ftp.gnu.org/gnu/autoconf
ftp://ftp.gnu.org/gnu/automake
ftp://ftp.gnu.org/gnu/libtool
ftp://ftp.gnu.org/gnu/gettext
The required versions of the tools for this tree are
autoconf 2.69
automake 1.15.1
libtool 2.2.6
gettext 0.14.5
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.

270
ar-lib Executable file
View File

@ -0,0 +1,270 @@
#! /bin/sh
# Wrapper for Microsoft lib.exe
me=ar-lib
scriptversion=2012-03-01.08; # UTC
# Copyright (C) 2010-2017 Free Software Foundation, Inc.
# Written by Peter Rosin <peda@lysator.liu.se>.
#
# 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, 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/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# func_error message
func_error ()
{
echo "$me: $1" 1>&2
exit 1
}
file_conv=
# func_file_conv build_file
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv in
mingw)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin)
file=`cygpath -m "$file" || echo "$file"`
;;
wine)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_at_file at_file operation archive
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
# for each of them.
# When interpreting the content of the @FILE, do NOT use func_file_conv,
# since the user would need to supply preconverted file names to
# binutils ar, at least for MinGW.
func_at_file ()
{
operation=$2
archive=$3
at_file_contents=`cat "$1"`
eval set x "$at_file_contents"
shift
for member
do
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
done
}
case $1 in
'')
func_error "no command. Try '$0 --help' for more information."
;;
-h | --h*)
cat <<EOF
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
Members may be specified in a file named with @FILE.
EOF
exit $?
;;
-v | --v*)
echo "$me, version $scriptversion"
exit $?
;;
esac
if test $# -lt 3; then
func_error "you must specify a program, an action and an archive"
fi
AR=$1
shift
while :
do
if test $# -lt 2; then
func_error "you must specify a program, an action and an archive"
fi
case $1 in
-lib | -LIB \
| -ltcg | -LTCG \
| -machine* | -MACHINE* \
| -subsystem* | -SUBSYSTEM* \
| -verbose | -VERBOSE \
| -wx* | -WX* )
AR="$AR $1"
shift
;;
*)
action=$1
shift
break
;;
esac
done
orig_archive=$1
shift
func_file_conv "$orig_archive"
archive=$file
# strip leading dash in $action
action=${action#-}
delete=
extract=
list=
quick=
replace=
index=
create=
while test -n "$action"
do
case $action in
d*) delete=yes ;;
x*) extract=yes ;;
t*) list=yes ;;
q*) quick=yes ;;
r*) replace=yes ;;
s*) index=yes ;;
S*) ;; # the index is always updated implicitly
c*) create=yes ;;
u*) ;; # TODO: don't ignore the update modifier
v*) ;; # TODO: don't ignore the verbose modifier
*)
func_error "unknown action specified"
;;
esac
action=${action#?}
done
case $delete$extract$list$quick$replace,$index in
yes,* | ,yes)
;;
yesyes*)
func_error "more than one action specified"
;;
*)
func_error "no action specified"
;;
esac
if test -n "$delete"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
for member
do
case $1 in
@*)
func_at_file "${1#@}" -REMOVE "$archive"
;;
*)
func_file_conv "$1"
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
;;
esac
done
elif test -n "$extract"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
if test $# -gt 0; then
for member
do
case $1 in
@*)
func_at_file "${1#@}" -EXTRACT "$archive"
;;
*)
func_file_conv "$1"
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
;;
esac
done
else
$AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
do
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
done
fi
elif test -n "$quick$replace"; then
if test ! -f "$orig_archive"; then
if test -z "$create"; then
echo "$me: creating $orig_archive"
fi
orig_archive=
else
orig_archive=$archive
fi
for member
do
case $1 in
@*)
func_file_conv "${1#@}"
set x "$@" "@$file"
;;
*)
func_file_conv "$1"
set x "$@" "$file"
;;
esac
shift
shift
done
if test -n "$orig_archive"; then
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
else
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
fi
elif test -n "$list"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
$AR -NOLOGO -LIST "$archive" || exit $?
fi

40
bfd/.gitignore vendored Normal file
View File

@ -0,0 +1,40 @@
/bfd-in3.h
/bfd.h
/bfd_stdint.h
/bfdver.h
/elf32-ia64.c
/elf32-target.h
/elf64-ia64.c
/elf64-target.h
/libtool-soversion
/ofiles
/peigen.c
/pepigen.c
/pex64igen.c
/stmp-bfd-h
/targmatch.h
/doc/aoutx.texi
/doc/archive.texi
/doc/archures.texi
/doc/bfdio.texi
/doc/bfdt.texi
/doc/bfdver.texi
/doc/bfdwin.texi
/doc/cache.texi
/doc/chew
/doc/coffcode.texi
/doc/core.texi
/doc/elf.texi
/doc/elfcode.texi
/doc/format.texi
/doc/hash.texi
/doc/init.texi
/doc/libbfd.texi
/doc/linker.texi
/doc/mmo.texi
/doc/opncls.texi
/doc/reloc.texi
/doc/section.texi
/doc/syms.texi
/doc/targets.texi

674
bfd/COPYING Normal file
View 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>.

3011
bfd/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

9598
bfd/ChangeLog-0001 Normal file

File diff suppressed because it is too large Load Diff

11411
bfd/ChangeLog-0203 Normal file

File diff suppressed because it is too large Load Diff

5069
bfd/ChangeLog-2004 Normal file

File diff suppressed because it is too large Load Diff

5275
bfd/ChangeLog-2005 Normal file

File diff suppressed because it is too large Load Diff

3607
bfd/ChangeLog-2006 Normal file

File diff suppressed because it is too large Load Diff

3567
bfd/ChangeLog-2007 Normal file

File diff suppressed because it is too large Load Diff

3392
bfd/ChangeLog-2008 Normal file

File diff suppressed because it is too large Load Diff

5161
bfd/ChangeLog-2009 Normal file

File diff suppressed because it is too large Load Diff

3568
bfd/ChangeLog-2010 Normal file

File diff suppressed because it is too large Load Diff

3389
bfd/ChangeLog-2011 Normal file

File diff suppressed because it is too large Load Diff

3300
bfd/ChangeLog-2012 Normal file

File diff suppressed because it is too large Load Diff

3239
bfd/ChangeLog-2013 Normal file

File diff suppressed because it is too large Load Diff

3430
bfd/ChangeLog-2014 Normal file

File diff suppressed because it is too large Load Diff

4247
bfd/ChangeLog-2015 Normal file

File diff suppressed because it is too large Load Diff

4293
bfd/ChangeLog-2016 Normal file

File diff suppressed because it is too large Load Diff

5727
bfd/ChangeLog-2017 Normal file

File diff suppressed because it is too large Load Diff

4949
bfd/ChangeLog-2018 Normal file

File diff suppressed because it is too large Load Diff

7854
bfd/ChangeLog-9193 Normal file

File diff suppressed because it is too large Load Diff

10049
bfd/ChangeLog-9495 Normal file

File diff suppressed because it is too large Load Diff

6735
bfd/ChangeLog-9697 Normal file

File diff suppressed because it is too large Load Diff

5605
bfd/ChangeLog-9899 Normal file

File diff suppressed because it is too large Load Diff

7
bfd/MAINTAINERS Normal file
View File

@ -0,0 +1,7 @@
See ../binutils/MAINTAINERS
Copyright (C) 2012-2019 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

1003
bfd/Makefile.am Normal file

File diff suppressed because it is too large Load Diff

2122
bfd/Makefile.in Normal file

File diff suppressed because it is too large Load Diff

89
bfd/PORTING Normal file
View File

@ -0,0 +1,89 @@
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.ac 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.ac, 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>"
Copyright (C) 2012-2019 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

55
bfd/README Normal file
View File

@ -0,0 +1,55 @@
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.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

27
bfd/TODO Normal file
View File

@ -0,0 +1,27 @@
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.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

89
bfd/acinclude.m4 Normal file
View File

@ -0,0 +1,89 @@
dnl
dnl Copyright (C) 2012-2019 Free Software Foundation, Inc.
dnl
dnl This file is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING3. If not see
dnl <http://www.gnu.org/licenses/>.
dnl
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)
AM_SUBST_NOTMAKE(bfdlibdir)
AC_SUBST(bfdincludedir)
AM_SUBST_NOTMAKE(bfdincludedir)
]
)

1189
bfd/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

281
bfd/aix386-core.c Normal file
View File

@ -0,0 +1,281 @@
/* 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 (C) 1988-2019 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 const bfd_target *
aix386_core_file_p (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 (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 (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 (bfd *abfd)
{
return core_hdr (abfd)->cd_comm;
}
static int
aix386_core_file_failing_signal (bfd *abfd)
{
return core_hdr (abfd)->cd_cursig;
}
#define aix386_core_file_matches_executable_p generic_core_file_matches_executable_p
#define aix386_core_file_pid _bfd_nocore_core_file_pid
/* If somebody calls any byte-swapping routines, shoot them. */
static void
swap_abort (void)
{
/* 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 core_aix386_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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
_bfd_dummy_target,
_bfd_dummy_target,
aix386_core_file_p
},
{ /* bfd_create_object */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error
},
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,
NULL
};

357
bfd/aix5ppc-core.c Normal file
View File

@ -0,0 +1,357 @@
/* IBM RS/6000 "XCOFF" back-end for BFD.
Copyright (C) 2001-2019 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 */

292
bfd/aout-cris.c Normal file
View File

@ -0,0 +1,292 @@
/* BFD backend for CRIS a.out binaries.
Copyright (C) 2000-2019 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"
/* 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 "sysdep.h"
#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, EXECP) \
MY_set_arch_mach (BFD, DEFAULT_ARCH, N_MACHTYPE (EXECP))
/* 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_asymbol_section (sym)))
{
r_extern = 0;
r_index = N_ABS;
}
else if ((sym->flags & BSF_SECTION_SYM) == 0)
{
if (bfd_is_und_section (bfd_asymbol_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)
{
/* xgettext:c-format */
_bfd_error_handler (_("%pB: unsupported relocation type exported: %#x"),
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)
{
/* xgettext:c-format */
_bfd_error_handler (_("%pB: unsupported relocation type imported: %#x"),
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
/* xgettext:c-format */
(_("%pB: 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
bfd/aout-ns32k.c Normal file
View File

@ -0,0 +1,364 @@
/* BFD back-end for ns32k a.out-ish binaries.
Copyright (C) 1990-2019 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 "sysdep.h"
#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 (ns32k_aout_,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_arch_bits_per_address (abfd))
{
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)
|| bfd_is_abs_section (output_section)
|| bfd_is_und_section (output_section))
{
if (bfd_abs_section_ptr->symbol == sym)
{
/* Whoops, looked like an abs symbol, but is really an offset
from the abs section. */
r_index = 0;
r_extern = 0;
}
else
{
/* Fill in symbol. */
r_extern = 1;
#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);
}

711
bfd/aout-target.h Normal file
View File

@ -0,0 +1,711 @@
/* Define a target vector and some small routines for a variant of a.out.
Copyright (C) 1990-2019 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 _bfd_bsd_write_armap
#endif
#ifndef MY_read_ar_hdr
#define MY_read_ar_hdr _bfd_generic_read_ar_hdr
#endif
#ifndef MY_write_ar_hdr
#define MY_write_ar_hdr _bfd_generic_write_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_pid
#define MY_core_file_pid _bfd_nocore_core_file_pid
#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_bfd
#endif
#ifndef MY_bfd_debug_info_end
#define MY_bfd_debug_info_end _bfd_void_bfd
#endif
#ifndef MY_bfd_debug_info_accumulate
#define MY_bfd_debug_info_accumulate _bfd_void_bfd_asection
#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_set_reloc
#define MY_set_reloc _bfd_generic_set_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_symbol_version_string
#define MY_get_symbol_version_string \
_bfd_nosymbols_get_symbol_version_string
#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_line
#define MY_find_line _bfd_nosymbols_find_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_lookup_section_flags
#define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags
#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_group_name
#define MY_bfd_group_name bfd_generic_group_name
#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_define_common_symbol
#define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
#endif
#ifndef MY_bfd_link_hide_symbol
#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#endif
#ifndef MY_bfd_define_start_stop
#define MY_bfd_define_start_stop bfd_generic_define_start_stop
#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_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_copy_link_hash_symbol_type
#define MY_bfd_copy_link_hash_symbol_type \
_bfd_generic_copy_link_hash_symbol_type
#endif
#ifndef MY_bfd_link_split_section
#define MY_bfd_link_split_section _bfd_generic_link_split_section
#endif
#ifndef MY_bfd_link_check_relocs
#define MY_bfd_link_check_relocs _bfd_generic_link_check_relocs
#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_bool_bfd_asymbol_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
/* Handle closing of a BFD including the resource-releasing parts. */
static bfd_boolean
MY_close_and_cleanup (bfd *abfd)
{
if (!MY_bfd_free_cached_info (abfd))
return FALSE;
return _bfd_generic_close_and_cleanup (abfd);
}
#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. */
0, /* match priority. */
#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_check_format. */
_bfd_dummy_target,
MY_object_p,
bfd_generic_archive_p,
MY_core_file_p
},
{ /* bfd_set_format. */
_bfd_bool_bfd_false_error,
MY_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
MY_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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 */

1173
bfd/aout-tic30.c Normal file

File diff suppressed because it is too large Load Diff

24
bfd/aout32.c Normal file
View File

@ -0,0 +1,24 @@
/* BFD back-end for 32-bit a.out files.
Copyright (C) 1990-2019 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
bfd/aout64.c Normal file
View File

@ -0,0 +1,32 @@
/* BFD back-end for 64-bit a.out files.
Copyright (C) 1990-2019 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"

5700
bfd/aoutx.h Normal file

File diff suppressed because it is too large Load Diff

542
bfd/arc-got.h Normal file
View File

@ -0,0 +1,542 @@
/* ARC-specific support for 32-bit ELF
Copyright (C) 1994-2019 Free Software Foundation, Inc.
Contributed by Cupertino Miranda (cmiranda@synopsys.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. */
#ifndef ARC_GOT_H
#define ARC_GOT_H
#define TCB_SIZE (8)
#define align_power(addr, align) \
(((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align))))
enum tls_type_e
{
GOT_UNKNOWN = 0,
GOT_NORMAL,
GOT_TLS_GD,
GOT_TLS_IE,
GOT_TLS_LE
};
enum tls_got_entries
{
TLS_GOT_NONE = 0,
TLS_GOT_MOD,
TLS_GOT_OFF,
TLS_GOT_MOD_AND_OFF
};
struct got_entry
{
struct got_entry *next;
enum tls_type_e type;
bfd_vma offset;
bfd_boolean processed;
bfd_boolean created_dyn_relocation;
enum tls_got_entries existing_entries;
};
/* Return the local got list, if not defined, create an empty one. */
static struct got_entry **
arc_get_local_got_ents (bfd * abfd)
{
if (elf_local_got_ents (abfd) == NULL)
{
bfd_size_type amt = (elf_tdata (abfd)->symtab_hdr.sh_info
* sizeof (*elf_local_got_ents (abfd)));
elf_local_got_ents (abfd) = bfd_zmalloc (amt);
if (elf_local_got_ents (abfd) == NULL)
{
_bfd_error_handler (_("%pB: cannot allocate memory for local "
"GOT entries"), abfd);
bfd_set_error (bfd_error_bad_value);
return NULL;
}
}
return elf_local_got_ents (abfd);
}
static struct got_entry *
got_entry_for_type (struct got_entry **list,
enum tls_type_e type)
{
struct got_entry **p = list;
while (*p != NULL)
{
if ((*p)->type == type)
return *p;
p = &((*p)->next);
}
return NULL;
}
static void
new_got_entry_to_list (struct got_entry **list,
enum tls_type_e type,
bfd_vma offset,
enum tls_got_entries existing_entries)
{
/* Find list end. Avoid having multiple entries of the same
type. */
struct got_entry **p = list;
struct got_entry *entry;
while (*p != NULL)
{
if ((*p)->type == type)
return;
p = &((*p)->next);
}
entry = (struct got_entry *) xmalloc (sizeof (struct got_entry));
entry->type = type;
entry->offset = offset;
entry->next = NULL;
entry->processed = FALSE;
entry->created_dyn_relocation = FALSE;
entry->existing_entries = existing_entries;
ARC_DEBUG ("New GOT got entry added to list: "
"type: %d, offset: %ld, existing_entries: %d\n",
type, (long) offset, existing_entries);
/* Add the entry to the end of the list. */
*p = entry;
}
static enum tls_type_e
tls_type_for_reloc (reloc_howto_type *howto)
{
enum tls_type_e ret = GOT_UNKNOWN;
if (is_reloc_for_GOT (howto))
return GOT_NORMAL;
switch (howto->type)
{
case R_ARC_TLS_GD_GOT:
ret = GOT_TLS_GD;
break;
case R_ARC_TLS_IE_GOT:
ret = GOT_TLS_IE;
break;
case R_ARC_TLS_LE_32:
ret = GOT_TLS_LE;
break;
default:
ret = GOT_UNKNOWN;
break;
}
return ret;
};
static struct got_entry **
get_got_entry_list_for_symbol (bfd *abfd,
unsigned long r_symndx,
struct elf_link_hash_entry *h)
{
struct elf_arc_link_hash_entry *h1 =
((struct elf_arc_link_hash_entry *) h);
if (h1 != NULL)
{
return &h1->got_ents;
}
else
{
return arc_get_local_got_ents (abfd) + r_symndx;
}
}
static enum tls_type_e
arc_got_entry_type_for_reloc (reloc_howto_type *howto)
{
enum tls_type_e type = GOT_UNKNOWN;
if (is_reloc_for_GOT (howto))
return GOT_NORMAL;
if (is_reloc_for_TLS (howto))
{
switch (howto->type)
{
case R_ARC_TLS_GD_GOT:
type = GOT_TLS_GD;
break;
case R_ARC_TLS_IE_GOT:
type = GOT_TLS_IE;
break;
default:
break;
}
}
return type;
}
#define ADD_SYMBOL_REF_SEC_AND_RELOC(SECNAME, COND_FOR_RELOC, H) \
htab->s##SECNAME->size; \
{ \
if (COND_FOR_RELOC) \
{ \
htab->srel##SECNAME->size += sizeof (Elf32_External_Rela); \
ARC_DEBUG ("arc_info: Added reloc space in " \
#SECNAME " section at " __FILE__ \
":%d for symbol %s\n", \
__LINE__, name_for_global_symbol (H)); \
} \
if (H) \
if (H->dynindx == -1 && !H->forced_local) \
if (! bfd_elf_link_record_dynamic_symbol (info, H)) \
return FALSE; \
htab->s##SECNAME->size += 4; \
} \
static bfd_boolean
arc_fill_got_info_for_reloc (enum tls_type_e type,
struct got_entry **list,
struct bfd_link_info * info,
struct elf_link_hash_entry *h)
{
struct elf_link_hash_table *htab = elf_hash_table (info);
if (got_entry_for_type (list, type) != NULL)
return TRUE;
switch (type)
{
case GOT_NORMAL:
{
bfd_vma offset
= ADD_SYMBOL_REF_SEC_AND_RELOC (got, bfd_link_pic (info)
|| h != NULL, h);
new_got_entry_to_list (list, type, offset, TLS_GOT_NONE);
}
break;
case GOT_TLS_GD:
{
bfd_vma offset
= ADD_SYMBOL_REF_SEC_AND_RELOC (got, TRUE, h);
bfd_vma ATTRIBUTE_UNUSED notneeded
= ADD_SYMBOL_REF_SEC_AND_RELOC (got, TRUE, h);
new_got_entry_to_list (list, type, offset, TLS_GOT_MOD_AND_OFF);
}
break;
case GOT_TLS_IE:
case GOT_TLS_LE:
{
bfd_vma offset
= ADD_SYMBOL_REF_SEC_AND_RELOC (got, TRUE, h);
new_got_entry_to_list (list, type, offset, TLS_GOT_OFF);
}
break;
default:
return FALSE;
break;
}
return TRUE;
}
static bfd_vma
relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p,
enum tls_type_e type,
struct bfd_link_info * info,
bfd * output_bfd,
unsigned long r_symndx,
Elf_Internal_Sym * local_syms,
asection ** local_sections,
struct elf_link_hash_entry * h,
struct arc_relocation_data * reloc_data)
{
struct elf_link_hash_table *htab = elf_hash_table (info);
struct got_entry *entry = NULL;
if (list_p == NULL || type == GOT_UNKNOWN || type == GOT_TLS_LE)
return 0;
entry = got_entry_for_type (list_p, type);
BFD_ASSERT (entry);
if (h == NULL
|| h->forced_local == TRUE
|| (! elf_hash_table (info)->dynamic_sections_created
|| (bfd_link_pic (info)
&& SYMBOL_REFERENCES_LOCAL (info, h))))
{
const char ATTRIBUTE_UNUSED *symbol_name;
static const char local_name[] = "(local)";
asection *tls_sec = NULL;
bfd_vma sym_value = 0;
if (h != NULL)
{
// TODO: This should not be here.
reloc_data->sym_value = h->root.u.def.value;
reloc_data->sym_section = h->root.u.def.section;
sym_value = h->root.u.def.value
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset;
tls_sec = elf_hash_table (info)->tls_sec;
symbol_name = h->root.root.string;
}
else
{
Elf_Internal_Sym *sym = local_syms + r_symndx;
asection *sec = local_sections[r_symndx];
sym_value = sym->st_value
+ sec->output_section->vma
+ sec->output_offset;
tls_sec = elf_hash_table (info)->tls_sec;
symbol_name = local_name;
}
if (entry && !entry->processed)
{
switch (entry->type)
{
case GOT_TLS_GD:
{
BFD_ASSERT (tls_sec && tls_sec->output_section);
bfd_vma sec_vma = tls_sec->output_section->vma;
if (h == NULL || h->forced_local
|| !elf_hash_table (info)->dynamic_sections_created)
{
bfd_put_32 (output_bfd,
sym_value - sec_vma
+ (elf_hash_table (info)->dynamic_sections_created
? 0
: (align_power (0,
tls_sec->alignment_power))),
htab->sgot->contents + entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0));
ARC_DEBUG ("arc_info: FIXED -> %s value = %#lx "
"@ %lx, for symbol %s\n",
(entry->type == GOT_TLS_GD ? "GOT_TLS_GD" :
"GOT_TLS_IE"),
(long) (sym_value - sec_vma),
(long) (htab->sgot->output_section->vma
+ htab->sgot->output_offset
+ entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0)),
symbol_name);
}
}
break;
case GOT_TLS_IE:
{
BFD_ASSERT (tls_sec && tls_sec->output_section);
bfd_vma ATTRIBUTE_UNUSED sec_vma
= tls_sec->output_section->vma;
bfd_put_32 (output_bfd,
sym_value - sec_vma
+ (elf_hash_table (info)->dynamic_sections_created
? 0
: (align_power (TCB_SIZE,
tls_sec->alignment_power))),
htab->sgot->contents + entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0));
ARC_DEBUG ("arc_info: FIXED -> %s value = %#lx "
"@ %p, for symbol %s\n",
(entry->type == GOT_TLS_GD ? "GOT_TLS_GD" :
"GOT_TLS_IE"),
(long) (sym_value - sec_vma),
(long) (htab->sgot->output_section->vma
+ htab->sgot->output_offset
+ entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0)),
symbol_name);
}
break;
case GOT_NORMAL:
{
bfd_vma sec_vma
= reloc_data->sym_section->output_section->vma
+ reloc_data->sym_section->output_offset;
if (h != NULL
&& h->root.type == bfd_link_hash_undefweak)
ARC_DEBUG ("arc_info: PATCHED: NOT_PATCHED "
"@ %#08lx for sym %s in got offset %#lx "
"(is undefweak)\n",
(long) (htab->sgot->output_section->vma
+ htab->sgot->output_offset
+ entry->offset),
symbol_name,
(long) entry->offset);
else
{
bfd_put_32 (output_bfd,
reloc_data->sym_value + sec_vma,
htab->sgot->contents + entry->offset);
ARC_DEBUG ("arc_info: PATCHED: %#08lx "
"@ %#08lx for sym %s in got offset %#lx\n",
(long) (reloc_data->sym_value + sec_vma),
(long) (htab->sgot->output_section->vma
+ htab->sgot->output_offset + entry->offset),
symbol_name,
(long) entry->offset);
}
}
break;
default:
BFD_ASSERT (0);
break;
}
entry->processed = TRUE;
}
}
return entry->offset;
}
static void
create_got_dynrelocs_for_single_entry (struct got_entry *list,
bfd *output_bfd,
struct bfd_link_info * info,
struct elf_link_hash_entry *h)
{
if (list == NULL)
return;
bfd_vma got_offset = list->offset;
if (list->type == GOT_NORMAL
&& !list->created_dyn_relocation)
{
if (bfd_link_pic (info)
&& h != NULL
&& (info->symbolic || h->dynindx == -1)
&& h->def_regular)
{
ADD_RELA (output_bfd, got, got_offset, 0, R_ARC_RELATIVE, 0);
}
/* Do not fully understand the side effects of this condition.
The relocation space might still being reserved. Perhaps
I should clear its value. */
else if (h != NULL && h->dynindx != -1)
{
ADD_RELA (output_bfd, got, got_offset, h->dynindx, R_ARC_GLOB_DAT, 0);
}
list->created_dyn_relocation = TRUE;
}
else if (list->existing_entries != TLS_GOT_NONE
&& !list->created_dyn_relocation)
{
/* TODO TLS: This is not called for local symbols.
In order to correctly implement TLS, this should also
be called for all local symbols with tls got entries.
Should be moved to relocate_section in order to make it
work for local symbols. */
struct elf_link_hash_table *htab = elf_hash_table (info);
enum tls_got_entries e = list->existing_entries;
BFD_ASSERT (list->type != GOT_TLS_GD
|| list->existing_entries == TLS_GOT_MOD_AND_OFF);
bfd_vma dynindx = (h == NULL || h->dynindx == -1) ? 0 : h->dynindx;
if (e == TLS_GOT_MOD_AND_OFF || e == TLS_GOT_MOD)
{
ADD_RELA (output_bfd, got, got_offset, dynindx,
R_ARC_TLS_DTPMOD, 0);
ARC_DEBUG ("arc_info: TLS_DYNRELOC: type = %d, \
GOT_OFFSET = %#lx, GOT_VMA = %#lx, INDEX = %ld, ADDEND = 0x0\n",
list->type,
(long) got_offset,
(long) (htab->sgot->output_section->vma
+ htab->sgot->output_offset + got_offset),
(long) dynindx);
}
if (e == TLS_GOT_MOD_AND_OFF || e == TLS_GOT_OFF)
{
bfd_vma addend = 0;
if (list->type == GOT_TLS_IE)
{
addend = bfd_get_32 (output_bfd,
htab->sgot->contents + got_offset);
}
ADD_RELA (output_bfd, got,
got_offset + (e == TLS_GOT_MOD_AND_OFF ? 4 : 0),
dynindx,
(list->type == GOT_TLS_IE ? R_ARC_TLS_TPOFF
: R_ARC_TLS_DTPOFF),
addend);
ARC_DEBUG ("arc_info: TLS_DYNRELOC: type = %d, \
GOT_OFFSET = %#lx, GOT_VMA = %#lx, INDEX = %ld, ADDEND = %#lx\n",
list->type,
(long) got_offset,
(long) (htab->sgot->output_section->vma
+ htab->sgot->output_offset + got_offset),
(long) dynindx, (long) addend);
}
list->created_dyn_relocation = TRUE;
}
}
static void
create_got_dynrelocs_for_got_info (struct got_entry **list_p,
bfd *output_bfd,
struct bfd_link_info * info,
struct elf_link_hash_entry *h)
{
if (list_p == NULL)
return;
struct got_entry *list = *list_p;
/* Traverse the list of got entries for this symbol. */
while (list)
{
create_got_dynrelocs_for_single_entry (list, output_bfd, info, h);
list = list->next;
}
}
#undef ADD_SYMBOL_REF_SEC_AND_RELOC
#endif /* ARC_GOT_H */

94
bfd/arc-plt.def Normal file
View File

@ -0,0 +1,94 @@
/* Arc V2 Related PLT entries.
Copyright (C) 2016-2019 Free Software Foundation, Inc.
Contributed by Cupertino Miranda (cmiranda@synopsys.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. */
PLT_TYPE_START (ELF_ARCV2_PIC)
PLT_ENTRY (0x2730, 0x7f8b, 0x0000, 0x0000) /* ld %r11, [pcl,0] : 0 to be replaced by _DYNAMIC@GOTPC+4 */
PLT_ENTRY (0x2730, 0x7f8a, 0x0000, 0x0000) /* ld %r10, [pcl,0] : 0 to be replaced by _DYNAMIC@GOTPC+8 */
PLT_ENTRY (0x2020, 0x0280) /* j [%r10] */
PLT_ENTRY (0x0,0x0,0x0,0x0,0x0,0x0) /* padding */
PLT_ELEM (0x2730, 0x7f8c, 0x0000, 0x0000) /* ld %r12, [%pc,func@got] */
PLT_ELEM (0x2021, 0x0300) /* j.d [%r12] */
PLT_ELEM (0x240a, 0x1fc0) /* mov %r12, %pcl */
ENTRY_RELOC (4, 32, 0xFFFFFFFF, SGOT | RELATIVE_INSN_32 | MIDDLE_ENDIAN, 4)
ENTRY_RELOC (12, 32, 0xFFFFFFFF, SGOT | RELATIVE_INSN_32 | MIDDLE_ENDIAN, 8)
ENTRY_RELOC (20, 32, 0xFFFFFFFF, SGOT, 0)
ELEM_RELOC (4, 32, 0xFFFFFFFF, SGOT | RELATIVE_INSN_32 | MIDDLE_ENDIAN, 0)
PLT_TYPE_END (ELF_ARCV2_PIC)
PLT_TYPE_START (ELF_ARCV2_ABS)
PLT_ENTRY (0x1600,0x700b,0x0000,0x0000) /* ld %r11, [0] */
PLT_ENTRY (0x1600,0x700a,0x0000,0x0000) /* ld %r10, [0] */
PLT_ENTRY (0x2020,0x0280) /* j [%r10] */
PLT_ENTRY (0x0,0x0,0x0,0x0,0x0,0x0) /* padding */
PLT_ELEM (0x2730, 0x7f8c, 0x0000, 0x0000) /* ld %r12, [%pcl,func@gotpc] */
PLT_ELEM (0x2021,0x0300) /* j.d [%r12] */
PLT_ELEM (0x240a,0x1fc0) /* mov %r12, %pcl */
ENTRY_RELOC (4, 32, 0xFFFFFFFF, SGOT | MIDDLE_ENDIAN, 4)
ENTRY_RELOC (12, 32, 0xFFFFFFFF, SGOT | MIDDLE_ENDIAN, 8)
ENTRY_RELOC (20, 32, 0xFFFFFFFF, SGOT, 0)
ELEM_RELOC (4, 32, 0xFFFFFFFF, SGOT | RELATIVE_INSN_32 | MIDDLE_ENDIAN, 0)
PLT_TYPE_END (ELF_ARCV2_ABS)
/* Non Arc V2 Related PLT entries. */
PLT_TYPE_START (ELF_ARC_PIC)
PLT_ENTRY (0x2730,0x7f8b,0x0000,0x0000) /* ld %r11, [pcl,0] : 0 to be replaced by _DYNAMIC@GOTPC+4 */
PLT_ENTRY (0x2730,0x7f8a,0x0000,0x0000) /* ld %r10, [pcl,0] : 0 to be replaced by -DYNAMIC@GOTPC+8 */
PLT_ENTRY (0x2020,0x0280) /* j [%r10] */
PLT_ENTRY (0x0,0x0) /* padding */
PLT_ELEM (0x2730,0x7f8c,0x0000,0x0000) /* ld %r12, [%pc,func@got] */
PLT_ELEM (0x7c20) /* j_s.d [%r12] */
PLT_ELEM (0x74ef) /* mov_s %r12, %pcl */
ENTRY_RELOC (4, 32, 0xFFFFFFFF, SGOT | RELATIVE_INSN_32 | MIDDLE_ENDIAN, 4)
ENTRY_RELOC (12, 32, 0xFFFFFFFF, SGOT | RELATIVE_INSN_32 | MIDDLE_ENDIAN, 8)
ENTRY_RELOC (20, 32, 0xFFFFFFFF, SGOT, 0)
ELEM_RELOC (4, 32, 0xFFFFFFFF, SGOT | RELATIVE_INSN_32 | MIDDLE_ENDIAN, 0)
PLT_TYPE_END (ELF_ARC_PIC)
PLT_TYPE_START (ELF_ARC_ABS)
PLT_ENTRY (0x1600,0x700b,0x0000,0x0000) /* ld %r11, [0] */
PLT_ENTRY (0x1600,0x700a,0x0000,0x0000) /* ld %r10, [0] */
PLT_ENTRY (0x2020,0x0280) /* j [%r10] */
PLT_ENTRY (0x0,0x0) /* padding */
PLT_ELEM (0x2730,0x7f8c,0x0000,0x0000) /* ld %r12, [%pc,func@gotpc] */
PLT_ELEM (0x7c20,0x74ef) /* mov_s %r12, %pcl */
ENTRY_RELOC (4, 32, 0xFFFFFFFF, SGOT | MIDDLE_ENDIAN, 4)
ENTRY_RELOC (12, 32, 0xFFFFFFFF, SGOT | MIDDLE_ENDIAN, 8)
ENTRY_RELOC (20, 32, 0xFFFFFFFF, SGOT, 0)
ELEM_RELOC (4, 32, 0xFFFFFFFF, SGOT | RELATIVE_INSN_32 | MIDDLE_ENDIAN, 0)
PLT_TYPE_END (ELF_ARC_ABS)

194
bfd/arc-plt.h Normal file
View File

@ -0,0 +1,194 @@
/* ARC-specific header file for PLT support.
Copyright (C) 2016-2019 Free Software Foundation, Inc.
Contributed by Cupertino Miranda (cmiranda@synopsys.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. */
#ifndef ARC_PLT_H
#define ARC_PLT_H
/* Instructions appear in memory as a sequence of half-words (16 bit);
individual half-words are represented on the target in target byte order.
We use 'unsigned short' on the host to represent the PLT templates,
and translate to target byte order as we copy to the target. */
typedef uint16_t insn_hword;
enum plt_reloc_symbol
{
LAST_RELOC = 0,
SGOT = 1,
RELATIVE = (1 << 8),
RELATIVE_INSN_32 = (1 << 9),
RELATIVE_INSN_24 = (1 << 10),
MIDDLE_ENDIAN = (1 << 11)
};
#define IS_RELATIVE(S) ((S & (RELATIVE | RELATIVE_INSN_24 | RELATIVE_INSN_32)) != 0)
#define IS_INSN_32(S) ((S & RELATIVE_INSN_32) != 0)
#define IS_INSN_24(S) ((S & RELATIVE_INSN_24) != 0)
#define IS_MIDDLE_ENDIAN(S) ((S & MIDDLE_ENDIAN) != 0)
#define SYM_ONLY(S) (S & 0xFF)
struct plt_reloc
{
bfd_vma offset;
bfd_vma size;
bfd_vma mask;
enum plt_reloc_symbol symbol;
bfd_vma addend;
};
#define PLT_TYPE_START(NAME) NAME,
#define PLT_TYPE_END(NAME)
#define PLT_ENTRY(...)
#define PLT_ELEM(...)
#define ENTRY_RELOC(...)
#define ELEM_RELOC(...)
enum plt_types_enum
{
PLT_START = -1,
#include "arc-plt.def"
PLT_MAX
};
#undef PLT_TYPE_START
#undef PLT_TYPE_END
#undef PLT_ENTRY
#undef PLT_ELEM
#undef ENTRY_RELOC
#undef ELEM_RELOC
typedef insn_hword insn_hword_array[];
struct plt_version_t
{
const insn_hword_array *entry;
const bfd_vma entry_size;
const insn_hword_array *elem;
const bfd_vma elem_size;
const struct plt_reloc *entry_relocs;
const struct plt_reloc *elem_relocs;
};
#define PLT_TYPE_START(NAME) \
const insn_hword NAME##_plt_entry[] = {
#define PLT_TYPE_END(NAME) };
#define PLT_ENTRY(...) __VA_ARGS__,
#define PLT_ELEM(...)
#define ENTRY_RELOC(...)
#define ELEM_RELOC(...)
#include "arc-plt.def"
#undef PLT_TYPE_START
#undef PLT_TYPE_END
#undef PLT_ENTRY
#undef PLT_ELEM
#undef ENTRY_RELOC
#undef ELEM_RELOC
#define PLT_TYPE_START(NAME) \
const struct plt_reloc NAME##_plt_entry_relocs[] = {
#define PLT_TYPE_END(NAME) \
{0, 0, 0, LAST_RELOC, 0} \
};
#define PLT_ENTRY(...)
#define PLT_ELEM(...)
#define ENTRY_RELOC(...) { __VA_ARGS__ },
#define ELEM_RELOC(...)
#include "arc-plt.def"
#undef PLT_TYPE_START
#undef PLT_TYPE_END
#undef PLT_ENTRY
#undef PLT_ELEM
#undef ENTRY_RELOC
#undef ELEM_RELOC
#define PLT_TYPE_START(NAME) \
const insn_hword NAME##_plt_elem[] = {
#define PLT_TYPE_END(NAME) };
#define PLT_ENTRY(...)
#define PLT_ELEM(...) __VA_ARGS__,
#define ENTRY_RELOC(...)
#define ELEM_RELOC(...)
#include "arc-plt.def"
#undef PLT_TYPE_START
#undef PLT_TYPE_END
#undef PLT_ENTRY
#undef PLT_ELEM
#undef ENTRY_RELOC
#undef ELEM_RELOC
#define PLT_TYPE_START(NAME) \
const struct plt_reloc NAME##_plt_elem_relocs[] = {
#define PLT_TYPE_END(NAME) \
{0, 0, 0, LAST_RELOC, 0} \
};
#define PLT_ENTRY(...)
#define PLT_ELEM(...)
#define ENTRY_RELOC(...)
#define ELEM_RELOC(...) { __VA_ARGS__ },
#include "arc-plt.def"
#undef PLT_TYPE_START
#undef PLT_TYPE_END
#undef PLT_ENTRY
#undef PLT_ELEM
#undef ENTRY_RELOC
#undef ELEM_RELOC
#define PLT_TYPE_START(NAME) \
{ \
.entry = &NAME##_plt_entry, \
.entry_size = sizeof (NAME##_plt_entry), \
.elem = &NAME##_plt_elem, \
.elem_size = sizeof (NAME##_plt_elem), \
.entry_relocs = NAME##_plt_entry_relocs, \
.elem_relocs = NAME##_plt_elem_relocs
#define PLT_TYPE_END(NAME) },
#define PLT_ENTRY(...)
#define PLT_ELEM(...)
#define ENTRY_RELOC(...)
#define ELEM_RELOC(...)
struct plt_version_t plt_versions[PLT_MAX] = {
#include "arc-plt.def"
};
#undef PLT_TYPE_START
#undef PLT_TYPE_END
#undef PLT_ENTRY
#undef PLT_ELEM
#undef ENTRY_RELOC
#undef ELEM_RELOC
#endif /* ARC_PLT_H */

2851
bfd/archive.c Normal file

File diff suppressed because it is too large Load Diff

253
bfd/archive64.c Normal file
View File

@ -0,0 +1,253 @@
/* Support for 64-bit archives.
Copyright (C) 1996-2019 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 archives. We use the same format as
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. */
/* Read an Irix 6 armap. */
bfd_boolean
_bfd_archive_64_bit_slurp_armap (bfd *abfd)
{
struct artdata *ardata = bfd_ardata (abfd);
char nextname[17];
bfd_size_type i, parsed_size, nsymz, stringsize, carsym_size, ptrsize;
struct areltdata *mapdata;
bfd_byte int_buf[8];
char *stringbase;
char *stringend;
bfd_byte *raw_armap = NULL;
carsym *carsyms;
bfd_size_type amt;
ardata->symdefs = NULL;
/* Get the name of the first element. */
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/ "))
{
abfd->has_armap = FALSE;
return TRUE;
}
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
if (mapdata == NULL)
return FALSE;
parsed_size = mapdata->parsed_size;
free (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;
if (/* Catch overflow in stringsize (and ptrsize) expression. */
nsymz >= (bfd_size_type) -1 / 8
|| stringsize > parsed_size
/* Catch overflow in carsym_size expression. */
|| nsymz > (bfd_size_type) -1 / sizeof (carsym)
/* Catch overflow in amt expression. */
|| amt <= carsym_size
|| amt <= stringsize)
{
bfd_set_error (bfd_error_malformed_archive);
return FALSE;
}
ardata->symdefs = (struct carsym *) bfd_zalloc (abfd, amt);
if (ardata->symdefs == NULL)
return FALSE;
carsyms = ardata->symdefs;
stringbase = ((char *) ardata->symdefs) + carsym_size;
raw_armap = (bfd_byte *) 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;
}
stringend = stringbase + stringsize;
*stringend = 0;
for (i = 0; i < nsymz; i++)
{
carsyms->file_offset = bfd_getb64 (raw_armap + i * 8);
carsyms->name = stringbase;
stringbase += strlen (stringbase);
if (stringbase != stringend)
++stringbase;
++carsyms;
}
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;
abfd->has_armap = 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_archive_64_bit_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/"));
if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize))
return FALSE;
_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. */
count = 0;
for (current = arch->archive_head;
current != NULL && count < symbol_count;
current = current->archive_next)
{
/* For each symbol which is used defined in this object, write out
the object file's address in the archive. */
for (;
count < symbol_count && map[count].u.abfd == current;
count++)
{
bfd_putb64 ((bfd_vma) archive_member_file_ptr, buf);
if (bfd_bwrite (buf, 8, arch) != 8)
return FALSE;
}
/* Add size of this archive entry */
archive_member_file_ptr += sizeof (struct ar_hdr);
if (! bfd_is_thin_archive (arch))
archive_member_file_ptr += arelt_size (current);
/* remember about the even alignment */
archive_member_file_ptr += archive_member_file_ptr % 2;
}
/* 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;
}

1461
bfd/archures.c Normal file

File diff suppressed because it is too large Load Diff

566
bfd/bfd-in.h Normal file
View File

@ -0,0 +1,566 @@
/* Main header file for the bfd library -- portable access to object files.
Copyright (C) 1990-2019 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__
/* PR 14072: Ensure that config.h is included first. */
#if !defined PACKAGE && !defined PACKAGE_VERSION
#error config.h must be included before this header
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include "ansidecl.h"
#include "symcat.h"
#include "bfd_stdint.h"
#include "diagnostics.h"
#include <stdarg.h>
#include <sys/stat.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))
#define BFD_SUPPORTS_PLUGINS @supports_plugins@
/* 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
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if BFD_HOST_64BIT_LONG
# define BFD_PRI64 "l"
# elif defined (__MSVCRT__)
# define BFD_PRI64 "I64"
# else
# define BFD_PRI64 "ll"
# endif
# undef PRId64
# define PRId64 BFD_PRI64 "d"
# undef PRIu64
# define PRIu64 BFD_PRI64 "u"
# undef PRIx64
# define PRIx64 BFD_PRI64 "x"
#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;
#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
/* A canonical archive symbol. */
/* This is a type pun with struct ranlib on purpose! */
typedef struct carsym
{
const 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. */
typedef struct bfd_section *sec_ptr;
#define align_power(addr, align) \
(((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align))))
/* Align an address upward to a boundary, expressed as a number of bytes.
E.g. align to an 8-byte boundary with argument of 8. Take care never
to wrap around if the address is within boundary-1 of the end of the
address space. */
#define BFD_ALIGN(this, boundary) \
((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \
: ~ (bfd_vma) 0)
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);
/* Rename an entry in a hash table. */
extern void bfd_hash_rename
(struct bfd_hash_table *, const char *, struct bfd_hash_entry *);
/* 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 unsigned long bfd_hash_set_default_size (unsigned long);
/* Types of compressed DWARF debug sections. We currently support
zlib. */
enum compressed_debug_section_type
{
COMPRESS_DEBUG_NONE = 0,
COMPRESS_DEBUG = 1 << 0,
COMPRESS_DEBUG_GNU_ZLIB = COMPRESS_DEBUG | 1 << 1,
COMPRESS_DEBUG_GABI_ZLIB = COMPRESS_DEBUG | 1 << 2
};
/* 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) \
(_bfd_warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
(_bfd_warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
#else
#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
(_bfd_warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
(_bfd_warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
#endif
extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
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_putb24 (bfd_vma, void *);
void bfd_putl24 (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);
/* 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);
/* Externally visible ELF routines. */
/* 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 non-zero, SIZE is the known extent of the
object. 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 a 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_size_type size, bfd_vma *loadbasep,
int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
bfd_size_type len));
/* Forward declarations. */
struct ecoff_debug_info;
struct ecoff_debug_swap;
struct ecoff_extr;
struct bfd_link_info;
struct bfd_link_hash_entry;

7837
bfd/bfd-in2.h Normal file

File diff suppressed because it is too large Load Diff

2856
bfd/bfd.c Normal file

File diff suppressed because it is too large Load Diff

61
bfd/bfd.m4 Normal file
View File

@ -0,0 +1,61 @@
dnl This file was derived from acinclude.m4.
dnl
dnl Copyright (C) 2012-2019 Free Software Foundation, Inc.
dnl
dnl This file is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING3. If not see
dnl <http://www.gnu.org/licenses/>.
dnl
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
/* Needed for new procfs interface on sparc-solaris. */
#define _STRUCTURED_PROC 1
#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
/* Needed for new procfs interface on sparc-solaris. */
#define _STRUCTURED_PROC 1
#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)
])

648
bfd/bfdio.c Normal file
View File

@ -0,0 +1,648 @@
/* Low-level I/O routines for BFDs.
Copyright (C) 1990-2019 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
#ifndef FD_CLOEXEC
#define FD_CLOEXEC 1
#endif
file_ptr
_bfd_real_ftell (FILE *file)
{
#if defined (HAVE_FTELLO64)
return ftello64 (file);
#elif defined (HAVE_FTELLO)
return ftello (file);
#else
return ftell (file);
#endif
}
int
_bfd_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
}
/* Mark FILE as close-on-exec. Return FILE. FILE may be NULL, in
which case nothing is done. */
static FILE *
close_on_exec (FILE *file)
{
#if defined (HAVE_FILENO) && defined (F_GETFD)
if (file)
{
int fd = fileno (file);
int old = fcntl (fd, F_GETFD, 0);
if (old >= 0)
fcntl (fd, F_SETFD, old | FD_CLOEXEC);
}
#endif
return file;
}
FILE *
_bfd_real_fopen (const char *filename, const char *modes)
{
#ifdef VMS
char *vms_attr;
/* On VMS, fopen allows file attributes as optional arguments.
We need to use them but we'd better to use the common prototype.
In fopen-vms.h, they are separated from the mode with a comma.
Split here. */
vms_attr = strchr (modes, ',');
if (vms_attr == NULL)
{
/* No attributes. */
return close_on_exec (fopen (filename, modes));
}
else
{
/* Attributes found. Split. */
size_t modes_len = strlen (modes) + 1;
char attrs[modes_len + 1];
char *at[3];
int i;
memcpy (attrs, modes, modes_len);
at[0] = attrs;
for (i = 0; i < 2; i++)
{
at[i + 1] = strchr (at[i], ',');
BFD_ASSERT (at[i + 1] != NULL);
*(at[i + 1]++) = 0; /* Replace ',' with a nul, and skip it. */
}
return close_on_exec (fopen (filename, at[0], at[1], at[2]));
}
#else /* !VMS */
#if defined (HAVE_FOPEN64)
return close_on_exec (fopen64 (filename, modes));
#else
return close_on_exec (fopen (filename, modes));
#endif
#endif /* !VMS */
}
/*
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);
. {* Mmap a part of the files. ADDR, LEN, PROT, FLAGS and OFFSET are the usual
. mmap parameter, except that LEN and OFFSET do not need to be page
. aligned. Returns (void *)-1 on failure, mmapped address on success.
. Also write in MAP_ADDR the address of the page aligned buffer and in
. MAP_LEN the size mapped (a page multiple). Use unmap with MAP_ADDR and
. MAP_LEN to unmap. *}
. void *(*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
. int prot, int flags, file_ptr offset,
. void **map_addr, bfd_size_type *map_len);
.};
.extern const struct bfd_iovec _bfd_memory_iovec;
*/
/* Return value is amount read. */
bfd_size_type
bfd_bread (void *ptr, bfd_size_type size, bfd *abfd)
{
file_ptr nread;
bfd *element_bfd = abfd;
ufile_ptr offset = 0;
while (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
{
offset += abfd->origin;
abfd = abfd->my_archive;
}
/* If this is an archive element, don't read past the end of
this element. */
if (element_bfd->arelt_data != NULL)
{
bfd_size_type maxbytes = arelt_size (element_bfd);
if (abfd->where < offset || abfd->where - offset >= maxbytes)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
if (abfd->where - offset + size > maxbytes)
size = maxbytes - (abfd->where - offset);
}
if (abfd->iovec == NULL)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
nread = abfd->iovec->bread (abfd, ptr, size);
if (nread != -1)
abfd->where += nread;
return nread;
}
bfd_size_type
bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd)
{
file_ptr nwrote;
while (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
abfd = abfd->my_archive;
if (abfd->iovec == NULL)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
nwrote = abfd->iovec->bwrite (abfd, ptr, size);
if (nwrote != -1)
abfd->where += nwrote;
if ((bfd_size_type) nwrote != size)
{
#ifdef ENOSPC
errno = ENOSPC;
#endif
bfd_set_error (bfd_error_system_call);
}
return nwrote;
}
file_ptr
bfd_tell (bfd *abfd)
{
ufile_ptr offset = 0;
file_ptr ptr;
while (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
{
offset += abfd->origin;
abfd = abfd->my_archive;
}
if (abfd->iovec == NULL)
return 0;
ptr = abfd->iovec->btell (abfd);
abfd->where = ptr;
return ptr - offset;
}
int
bfd_flush (bfd *abfd)
{
while (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
abfd = abfd->my_archive;
if (abfd->iovec == NULL)
return 0;
return abfd->iovec->bflush (abfd);
}
/* 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;
while (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
abfd = abfd->my_archive;
if (abfd->iovec == NULL)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
result = abfd->iovec->bstat (abfd, statbuf);
if (result < 0)
bfd_set_error (bfd_error_system_call);
return result;
}
/* Returns 0 for success, nonzero for failure (in which case bfd_get_error
can retrieve the error code). */
int
bfd_seek (bfd *abfd, file_ptr position, int direction)
{
int result;
ufile_ptr offset = 0;
while (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
{
offset += abfd->origin;
abfd = abfd->my_archive;
}
if (abfd->iovec == NULL)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
/* 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 += offset;
if ((direction == SEEK_CUR && position == 0)
|| (direction == SEEK_SET && (ufile_ptr) position == abfd->where))
return 0;
result = abfd->iovec->bseek (abfd, position, direction);
if (result != 0)
{
/* An EINVAL error probably means that the file offset was
absurd. */
if (errno == EINVAL)
bfd_set_error (bfd_error_file_truncated);
else
bfd_set_error (bfd_error_system_call);
}
else
{
/* Adjust `where' field. */
if (direction == SEEK_CUR)
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 (bfd_stat (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
ufile_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?".
*/
ufile_ptr
bfd_get_size (bfd *abfd)
{
struct stat buf;
if (bfd_stat (abfd, &buf) != 0)
return 0;
return buf.st_size;
}
/*
FUNCTION
bfd_get_file_size
SYNOPSIS
ufile_ptr bfd_get_file_size (bfd *abfd);
DESCRIPTION
Return the file size (as read from file system) for the file
associated with BFD @var{abfd}. It supports both normal files
and archive elements.
*/
ufile_ptr
bfd_get_file_size (bfd *abfd)
{
if (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
return arelt_size (abfd);
return bfd_get_size (abfd);
}
/*
FUNCTION
bfd_mmap
SYNOPSIS
void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
int prot, int flags, file_ptr offset,
void **map_addr, bfd_size_type *map_len);
DESCRIPTION
Return mmap()ed region of the file, if possible and implemented.
LEN and OFFSET do not need to be page aligned. The page aligned
address and length are written to MAP_ADDR and MAP_LEN.
*/
void *
bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
int prot, int flags, file_ptr offset,
void **map_addr, bfd_size_type *map_len)
{
while (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
{
offset += abfd->origin;
abfd = abfd->my_archive;
}
if (abfd->iovec == NULL)
{
bfd_set_error (bfd_error_invalid_operation);
return (void *) -1;
}
return abfd->iovec->bmmap (abfd, addr, len, prot, flags, offset,
map_addr, map_len);
}
/* Memory file I/O operations. */
static file_ptr
memory_bread (bfd *abfd, void *ptr, file_ptr size)
{
struct bfd_in_memory *bim;
bfd_size_type get;
bim = (struct bfd_in_memory *) 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);
return get;
}
static file_ptr
memory_bwrite (bfd *abfd, const void *ptr, file_ptr size)
{
struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream;
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_byte *) bfd_realloc_or_free (bim->buffer, newsize);
if (bim->buffer == NULL)
{
bim->size = 0;
return 0;
}
if (newsize > bim->size)
memset (bim->buffer + bim->size, 0, newsize - bim->size);
}
}
memcpy (bim->buffer + abfd->where, ptr, (size_t) size);
return size;
}
static file_ptr
memory_btell (bfd *abfd)
{
return abfd->where;
}
static int
memory_bseek (bfd *abfd, file_ptr position, int direction)
{
file_ptr nwhere;
struct bfd_in_memory *bim;
bim = (struct bfd_in_memory *) abfd->iostream;
if (direction == SEEK_SET)
nwhere = position;
else
nwhere = abfd->where + position;
if (nwhere < 0)
{
abfd->where = 0;
errno = EINVAL;
return -1;
}
if ((bfd_size_type)nwhere > 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 = nwhere;
/* Round up to cut down on memory fragmentation */
newsize = (bim->size + 127) & ~(bfd_size_type) 127;
if (newsize > oldsize)
{
bim->buffer = (bfd_byte *) bfd_realloc_or_free (bim->buffer, newsize);
if (bim->buffer == NULL)
{
errno = EINVAL;
bim->size = 0;
return -1;
}
memset (bim->buffer + oldsize, 0, newsize - oldsize);
}
}
else
{
abfd->where = bim->size;
errno = EINVAL;
bfd_set_error (bfd_error_file_truncated);
return -1;
}
}
return 0;
}
static int
memory_bclose (struct bfd *abfd)
{
struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream;
if (bim->buffer != NULL)
free (bim->buffer);
free (bim);
abfd->iostream = NULL;
return 0;
}
static int
memory_bflush (bfd *abfd ATTRIBUTE_UNUSED)
{
return 0;
}
static int
memory_bstat (bfd *abfd, struct stat *statbuf)
{
struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream;
memset (statbuf, 0, sizeof (*statbuf));
statbuf->st_size = bim->size;
return 0;
}
static void *
memory_bmmap (bfd *abfd ATTRIBUTE_UNUSED, void *addr ATTRIBUTE_UNUSED,
bfd_size_type len ATTRIBUTE_UNUSED, int prot ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED, file_ptr offset ATTRIBUTE_UNUSED,
void **map_addr ATTRIBUTE_UNUSED,
bfd_size_type *map_len ATTRIBUTE_UNUSED)
{
return (void *)-1;
}
const struct bfd_iovec _bfd_memory_iovec =
{
&memory_bread, &memory_bwrite, &memory_btell, &memory_bseek,
&memory_bclose, &memory_bflush, &memory_bstat, &memory_bmmap
};

264
bfd/bfdwin.c Normal file
View File

@ -0,0 +1,264 @@
/* Support for memory-mapped windows into a BFD.
Copyright (C) 1995-2019 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 of the window stuff is
used. Enabled by --with-mmap. */
#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, (unsigned long) 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 == NULL)
{
i = bfd_zmalloc (sizeof (bfd_window_internal));
if (i == NULL)
return FALSE;
i->data = NULL;
}
#ifdef HAVE_MMAP
if (ok_to_map
&& (i->data == NULL || 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
&& !bfd_is_thin_archive (abfd->my_archive))
{
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))
goto free_and_fail;
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 != NULL && i->size < size)
{
munmap (i->data, i->size);
i->data = NULL;
}
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);
windowp->data = 0;
if (debug_windows)
fprintf (stderr, "\t\tmmap failed!\n");
goto free_and_fail;
}
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;
i->refcount = 1;
windowp->i = i;
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)
{
windowp->i = i;
return TRUE;
}
goto free_and_fail;
}
i->refcount = 1;
if (bfd_seek (abfd, offset, SEEK_SET) != 0)
goto free_and_fail;
i->size = bfd_bread (i->data, size, abfd);
if (i->size != size)
goto free_and_fail;
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;
windowp->i = i;
return TRUE;
free_and_fail:
/* We have a bfd_window_internal, but an error occurred. Free it. */
free (i);
return FALSE;
}
#endif /* USE_MMAP */

376
bfd/binary.c Normal file
View File

@ -0,0 +1,376 @@
/* BFD back-end for binary objects.
Copyright (C) 1994-2019 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
/* 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;
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 = (char *) bfd_alloc (abfd, size);
if (buf == NULL)
return "";
sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
/* Change any non-alphanumeric characters to underscores. */
for (p = buf; *p; p++)
if (! ISALNUM (*p))
*p = '_';
return buf;
}
/* Return the symbol table. */
static long
binary_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 = (asymbol *) 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
#define binary_get_symbol_version_string \
_bfd_nosymbols_get_symbol_version_string
/* 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_line _bfd_nosymbols_find_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_bool_bfd_asymbol_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)
{
unsigned int opb = bfd_octets_per_byte (abfd, s);
s->filepos = (s->lma - low) * opb;
/* 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
/* xgettext:c-format */
(_("warning: writing section `%pA' at huge (ie negative) "
"file offset"),
s);
}
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_lookup_section_flags bfd_generic_lookup_section_flags
#define binary_bfd_merge_sections bfd_generic_merge_sections
#define binary_bfd_is_group_section bfd_generic_is_group_section
#define binary_bfd_group_name bfd_generic_group_name
#define binary_bfd_discard_group bfd_generic_discard_group
#define binary_section_already_linked _bfd_generic_section_already_linked
#define binary_bfd_define_common_symbol bfd_generic_define_common_symbol
#define binary_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define binary_bfd_define_start_stop bfd_generic_define_start_stop
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define binary_bfd_link_just_syms _bfd_generic_link_just_syms
#define binary_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type
#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
#define binary_bfd_link_check_relocs _bfd_generic_link_check_relocs
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 */
255, /* match priority. */
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_bool_bfd_false_error,
binary_mkobject,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_true,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
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
};

648
bfd/cache.c Normal file
View File

@ -0,0 +1,648 @@
/* BFD library -- caching of file descriptors.
Copyright (C) 1990-2019 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"
#ifdef HAVE_MMAP
#include <sys/mman.h>
#endif
/* 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. When needed call bfd_cache_max_open to initialize. */
static int max_open_files = 0;
/* Set max_open_files, if not already set, to 12.5% of the allowed open
file descriptors, but at least 10, and return the value. */
static int
bfd_cache_max_open (void)
{
if (max_open_files == 0)
{
int max;
#if defined(__sun) && !defined(__sparcv9) && !defined(__x86_64__)
/* PR ld/19260: 32-bit Solaris has very inelegant handling of the 255
file descriptor limit. The problem is that setrlimit(2) can raise
RLIMIT_NOFILE to a value that is not supported by libc, resulting
in "Too many open files" errors. This can happen here even though
max_open_files is set to rlim.rlim_cur / 8. For example, if
a parent process has set rlim.rlim_cur to 65536, then max_open_files
will be computed as 8192.
This check essentially reverts to the behavior from binutils 2.23.1
for 32-bit Solaris only. (It is hoped that the 32-bit libc
limitation will be removed soon). 64-bit Solaris libc does not have
this limitation. */
max = 16;
#else
#ifdef HAVE_GETRLIMIT
struct rlimit rlim;
if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
&& rlim.rlim_cur != (rlim_t) RLIM_INFINITY)
max = rlim.rlim_cur / 8;
else
#endif
#ifdef _SC_OPEN_MAX
max = sysconf (_SC_OPEN_MAX) / 8;
#else
max = 10;
#endif
#endif /* not 32-bit Solaris */
max_open_files = max < 10 ? 10 : max;
}
return max_open_files;
}
/* 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 *to_kill;
if (bfd_last_cache == NULL)
to_kill = NULL;
else
{
for (to_kill = bfd_last_cache->lru_prev;
! to_kill->cacheable;
to_kill = to_kill->lru_prev)
{
if (to_kill == bfd_last_cache)
{
to_kill = NULL;
break;
}
}
}
if (to_kill == NULL)
{
/* There are no open cacheable BFD's. */
return TRUE;
}
to_kill->where = _bfd_real_ftell ((FILE *) to_kill->iostream);
return bfd_cache_delete (to_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)
{
if ((abfd->flags & BFD_IN_MEMORY) != 0)
abort ();
if (abfd->my_archive != NULL
&& !bfd_is_thin_archive (abfd->my_archive))
abort ();
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)
&& _bfd_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;
/* xgettext:c-format */
_bfd_error_handler (_("reopening %pB: %s\n"),
abfd, 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 _bfd_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 : CACHE_NORMAL);
if (f == NULL)
return -1;
return _bfd_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 (FILE *f, void *buf, file_ptr nbytes)
{
file_ptr nread;
#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 nread;
}
#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 nread;
}
#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;
FILE *f;
f = bfd_cache_lookup (abfd, CACHE_NORMAL);
if (f == NULL)
return -1;
/* 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 (f, (char *) 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 *from, file_ptr nbytes)
{
file_ptr nwrite;
FILE *f = bfd_cache_lookup (abfd, CACHE_NORMAL);
if (f == NULL)
return 0;
nwrite = fwrite (from, 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) - 1;
}
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 void *
cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
void *addr ATTRIBUTE_UNUSED,
bfd_size_type len ATTRIBUTE_UNUSED,
int prot ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED,
file_ptr offset ATTRIBUTE_UNUSED,
void **map_addr ATTRIBUTE_UNUSED,
bfd_size_type *map_len ATTRIBUTE_UNUSED)
{
void *ret = (void *) -1;
if ((abfd->flags & BFD_IN_MEMORY) != 0)
abort ();
#ifdef HAVE_MMAP
else
{
static uintptr_t pagesize_m1;
FILE *f;
file_ptr pg_offset;
bfd_size_type pg_len;
f = bfd_cache_lookup (abfd, CACHE_NO_SEEK_ERROR);
if (f == NULL)
return ret;
if (pagesize_m1 == 0)
pagesize_m1 = getpagesize () - 1;
/* Align. */
pg_offset = offset & ~pagesize_m1;
pg_len = (len + (offset - pg_offset) + pagesize_m1) & ~pagesize_m1;
ret = mmap (addr, pg_len, prot, flags, fileno (f), pg_offset);
if (ret == (void *) -1)
bfd_set_error (bfd_error_system_call);
else
{
*map_addr = ret;
*map_len = pg_len;
ret = (char *) ret + (offset & pagesize_m1);
}
}
#endif
return ret;
}
static const struct bfd_iovec cache_iovec =
{
&cache_bread, &cache_bwrite, &cache_btell, &cache_bseek,
&cache_bclose, &cache_bflush, &cache_bstat, &cache_bmmap
};
/*
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 (void)
{
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 = _bfd_real_fopen (abfd->filename, FOPEN_RB);
break;
case both_direction:
case write_direction:
if (abfd->opened_once)
{
abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_RUB);
if (abfd->iostream == NULL)
abfd->iostream = _bfd_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 = _bfd_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
bfd/cf-i386lynx.c Normal file
View File

@ -0,0 +1,34 @@
/* BFD back-end for Intel 386 COFF LynxOS files.
Copyright (C) 1993-2019 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 i386_coff_lynx_vec
#define TARGET_NAME "coff-i386-lynx"
#define LYNXOS
#define COFF_LONG_FILENAMES
#define bfd_pe_print_pdata NULL
#include "coff-i386.c"

426
bfd/cisco-core.c Normal file
View File

@ -0,0 +1,426 @@
/* BFD back-end for CISCO crash dumps.
Copyright (C) 1994-2019 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;
};
#define cisco_core_file_matches_executable_p generic_core_file_matches_executable_p
#define cisco_core_file_pid _bfd_nocore_core_file_pid
/* Examine the file for a crash info struct at the offset given by
CRASH_INFO_LOC. */
static const bfd_target *
cisco_core_file_validate (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 (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);
}
static char *
cisco_core_file_failing_command (bfd *abfd ATTRIBUTE_UNUSED)
{
return NULL;
}
static int
cisco_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
{
return abfd->tdata.cisco_core_data->sig;
}
extern const bfd_target core_cisco_le_vec;
const bfd_target core_cisco_be_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 */
0, /* match priority. */
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_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error
},
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),
&core_cisco_le_vec,
NULL /* backend_data */
};
const bfd_target core_cisco_le_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 */
0, /* match_priority */
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_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error
},
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),
&core_cisco_be_vec,
NULL /* backend_data */
};

2459
bfd/coff-alpha.c Normal file

File diff suppressed because it is too large Load Diff

2566
bfd/coff-arm.c Normal file

File diff suppressed because it is too large Load Diff

29
bfd/coff-arm.h Normal file
View File

@ -0,0 +1,29 @@
/* BFD back-end for ARM COFF files.
Copyright (C) 2019 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. */
/* 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 *);

99
bfd/coff-bfd.c Normal file
View File

@ -0,0 +1,99 @@
/* BFD COFF interfaces used outside of BFD.
Copyright (C) 1990-2019 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/internal.h"
#include "libcoff.h"
/* Return the COFF syment for a symbol. */
bfd_boolean
bfd_coff_get_syment (bfd *abfd,
asymbol *symbol,
struct internal_syment *psyment)
{
coff_symbol_type *csym;
csym = coff_symbol_from (symbol);
if (csym == NULL || csym->native == NULL
|| ! csym->native->is_sym)
{
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
*psyment = csym->native->u.syment;
if (csym->native->fix_value)
psyment->n_value = psyment->n_value -
(bfd_hostptr_t) obj_raw_syments (abfd);
/* FIXME: We should handle fix_line here. */
return TRUE;
}
/* Return the COFF auxent for a symbol. */
bfd_boolean
bfd_coff_get_auxent (bfd *abfd,
asymbol *symbol,
int indx,
union internal_auxent *pauxent)
{
coff_symbol_type *csym;
combined_entry_type *ent;
csym = coff_symbol_from (symbol);
if (csym == NULL
|| csym->native == NULL
|| ! csym->native->is_sym
|| indx >= csym->native->u.syment.n_numaux)
{
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
ent = csym->native + indx + 1;
BFD_ASSERT (! ent->is_sym);
*pauxent = ent->u.auxent;
if (ent->fix_tag)
pauxent->x_sym.x_tagndx.l =
((combined_entry_type *) pauxent->x_sym.x_tagndx.p
- obj_raw_syments (abfd));
if (ent->fix_end)
pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l =
((combined_entry_type *) pauxent->x_sym.x_fcnary.x_fcn.x_endndx.p
- obj_raw_syments (abfd));
if (ent->fix_scnlen)
pauxent->x_csect.x_scnlen.l =
((combined_entry_type *) pauxent->x_csect.x_scnlen.p
- obj_raw_syments (abfd));
return TRUE;
}

91
bfd/coff-bfd.h Normal file
View File

@ -0,0 +1,91 @@
/* BFD COFF interfaces used outside of BFD.
Copyright (C) 1990-2019 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 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;
};
/* The used_by_bfd field of a section may be set to a pointer to this
structure. */
struct coff_section_tdata
{
/* The relocs, swapped into COFF internal form. This may be NULL. */
struct internal_reloc *relocs;
/* If this is TRUE, the relocs entry may not be freed. */
bfd_boolean keep_relocs;
/* The section contents. This may be NULL. */
bfd_byte *contents;
/* If this is TRUE, the contents entry may not be freed. */
bfd_boolean keep_contents;
/* Information cached by coff_find_nearest_line. */
bfd_boolean saved_bias;
bfd_signed_vma bias;
bfd_vma offset;
unsigned int i;
const char *function;
/* Optional information about a COMDAT entry; NULL if not COMDAT. */
struct coff_comdat_info *comdat;
int line_base;
/* A pointer used for .stab linking optimizations. */
void * stab_info;
/* Available for individual backends. */
void * tdata;
};
/* An accessor macro for the coff_section_tdata structure. */
#define coff_section_data(abfd, sec) \
((struct coff_section_tdata *) (sec)->used_by_bfd)
#define bfd_coff_get_comdat_section(abfd, sec) \
((bfd_get_flavour (abfd) == bfd_target_coff_flavour \
&& coff_section_data (abfd, sec) != NULL) \
? coff_section_data (abfd, sec)->comdat : NULL)
#define coff_symbol_from(symbol) \
((bfd_family_coff (bfd_asymbol_bfd (symbol)) \
&& bfd_asymbol_bfd (symbol)->tdata.coff_obj_data) \
? (coff_symbol_type *) (symbol) : NULL)
struct internal_syment;
union internal_auxent;
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);

45
bfd/coff-go32.c Normal file
View File

@ -0,0 +1,45 @@
/* BFD back-end for Intel 386 COFF files (DJGPP variant).
Copyright (C) 1990-2019 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 i386_coff_go32_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"

709
bfd/coff-i386.c Normal file
View File

@ -0,0 +1,709 @@
/* BFD back-end for Intel 386 COFF files.
Copyright (C) 1990-2019 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"
/* All users of this file have bfd_octets_per_byte (abfd, sec) == 1. */
#define OCTETS_PER_BYTE(ABFD, SEC) 1
static reloc_howto_type *coff_i386_rtype_to_howto
(bfd *, asection *, struct internal_reloc *,
struct coff_link_hash_entry *, struct internal_syment *,
bfd_vma *);
static reloc_howto_type *coff_i386_reloc_type_lookup
(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 (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
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;
bfd_size_type octets = (reloc_entry->address
* OCTETS_PER_BYTE (abfd, input_section));
unsigned char *addr = (unsigned char *) data + octets;
if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octets))
return bfd_reloc_outofrange;
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 (bfd * abfd ATTRIBUTE_UNUSED,
reloc_howto_type *howto)
{
return ! howto->pc_relative && howto->type != R_IMAGEBASE
&& howto->type != R_SECREL32;
}
#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 */
};
#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0]))
/* 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 < NUM_HOWTOS \
? 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 (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 < NUM_HOWTOS \
&& 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 (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 (bfd_link_relocatable (info))
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 (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 >= NUM_HOWTOS)
{
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;
}
/* PR 17099 - Absolute R_PCRLONG relocations do not need a symbol. */
if (rel->r_type == R_PCRLONG && sym == NULL)
*addendp -= rel->r_vaddr;
else
BFD_ASSERT (sym != NULL);
if (rel->r_type == R_SECREL32 && sym != NULL)
{
bfd_vma osect_vma;
if (h && (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak))
osect_vma = h->root.u.def.section->output_section->vma;
else
{
asection *s;
int i;
/* Sigh, the only way to get the section to offset against
is to find it the hard way. */
for (s = abfd->sections, i = 1; i < sym->n_scnum; i++)
s = s->next;
osect_vma = s->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 (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 < NUM_HOWTOS; 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 (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
i386_coff_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 | BFD_COMPRESS | BFD_DECOMPRESS ),
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
#ifdef COFF_WITH_PE
| SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
#endif
| SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
#ifdef TARGET_UNDERSCORE
TARGET_UNDERSCORE, /* leading underscore */
#else
0, /* leading underscore */
#endif
'/', /* ar_pad_char */
15, /* ar_max_namelen */
0, /* match priority. */
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. */
#ifdef COFF_CHECK_FORMAT
{ /* bfd_check_format */
_bfd_dummy_target,
COFF_CHECK_FORMAT,
bfd_generic_archive_p,
COFF_CHECK_FORMAT
},
#else
{
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
coff_object_p
},
#endif
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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
};

214
bfd/coff-ia64.c Normal file
View File

@ -0,0 +1,214 @@
/* BFD back-end for HP/Intel IA-64 COFF files.
Copyright (C) 1999-2019 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)
/* Windows ia64 uses 8K page size. */
#define COFF_PAGE_SIZE 0x2000
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;
#ifdef 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 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 (bfd *abfd)
{
#ifdef COFF_IMAGE_WITH_PE
{
struct external_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 IMAGE_DOS_SIGNATURE,
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) != IMAGE_DOS_SIGNATURE)
{
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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
ia64coff_object_p,
bfd_generic_archive_p,
ia64coff_object_p
},
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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
};

562
bfd/coff-mcore.c Normal file
View File

@ -0,0 +1,562 @@
/* BFD back-end for Motorola MCore COFF/PE
Copyright (C) 1999-2019 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
(bfd *, struct bfd_link_info *);
static bfd_reloc_status_type mcore_coff_unsupported_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
/* 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 (bfd * abfd,
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)
{
BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
/* xgettext: c-format */
_bfd_error_handler (_("%pB: 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 (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
#define NUM_HOWTOS NUM_ELEM (mcore_coff_howto_table)
static reloc_howto_type *
mcore_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
const char *r_name)
{
unsigned int i;
for (i = 0; i < NUM_HOWTOS; 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 = \
((dst)->r_type < NUM_HOWTOS \
? mcore_coff_howto_table + (dst)->r_type \
: NULL))
static reloc_howto_type *
coff_mcore_rtype_to_howto (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_HOWTOS)
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 (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 (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;
/* 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 (bfd_link_relocatable (info))
return TRUE;
/* Check if we have the same endianness */
if ( input_bfd->xvec->byteorder != output_bfd->xvec->byteorder
&& output_bfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
{
_bfd_error_handler
/* xgettext: c-format */
(_("%pB: 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;
}
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
(*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd, input_section,
rel->r_vaddr - input_section->vma, TRUE);
my_name = h->root.root.string;
}
rstat = bfd_reloc_ok;
/* Each case must do its own relocation, setting rstat appropriately. */
switch (r_type)
{
default:
/* xgettext: c-format */
_bfd_error_handler (_("%pB: unsupported relocation type %#x"),
input_bfd, r_type);
bfd_set_error (bfd_error_bad_value);
return FALSE;
case IMAGE_REL_MCORE_ABSOLUTE:
_bfd_error_handler
/* xgettext: c-format */
(_("warning: unsupported reloc %s <file %pB, section %pA>\n"
"sym %ld (%s), r_vaddr %" PRId64 " (%#" PRIx64 ")"),
howto->name, input_bfd, input_section,
rel->r_symndx, my_name, (int64_t) rel->r_vaddr,
(uint64_t) 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:
(*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 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)

1601
bfd/coff-mips.c Normal file

File diff suppressed because it is too large Load Diff

2621
bfd/coff-ppc.c Normal file

File diff suppressed because it is too large Load Diff

4409
bfd/coff-rs6000.c Normal file

File diff suppressed because it is too large Load Diff

3239
bfd/coff-sh.c Normal file

File diff suppressed because it is too large Load Diff

424
bfd/coff-stgo32.c Normal file
View File

@ -0,0 +1,424 @@
/* BFD back-end for Intel 386 COFF files (DJGPP variant with a stub).
Copyright (C) 1997-2019 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 i386_coff_go32stubbed_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 "sysdep.h"
#include "bfd.h"
/* 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. */
static void
adjust_filehdr_in_post (bfd *, void *, void *);
static void
adjust_filehdr_out_pre (bfd *, void *, void *);
static void
adjust_filehdr_out_post (bfd *, void *, void *);
static void
adjust_scnhdr_in_post (bfd *, void *, void *);
static void
adjust_scnhdr_out_pre (bfd *, void *, void *);
static void
adjust_scnhdr_out_post (bfd *, void *, void *);
static void
adjust_aux_in_post (bfd *, void *, int, int, int, int, void *);
static void
adjust_aux_out_pre (bfd *, void *, int, int, int, int, void *);
static void
adjust_aux_out_post (bfd *, void *, int, int, int, int, void *);
static void
create_go32_stub (bfd *);
#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 const bfd_target *go32_check_format (bfd *);
#define COFF_CHECK_FORMAT go32_check_format
static bfd_boolean
go32_stubbed_coff_bfd_copy_private_bfd_data (bfd *, bfd *);
#define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_data
#include "coff-i386.c"
/* This macro is used, because I cannot assume the endianness 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[GO32_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 GO32_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 (bfd * abfd ATTRIBUTE_UNUSED,
void * src,
void * dst)
{
FILHDR *filehdr_src = (FILHDR *) src;
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
ADJUST_VAL (filehdr_dst->f_symptr, GO32_STUBSIZE);
/* Save now the stub to be used later. Put the stub data to FILEHDR_DST
first as coff_data (abfd) still does not exist. It may not even be ever
created as we are just checking the file format of ABFD. */
memcpy (filehdr_dst->go32stub, filehdr_src->stub, GO32_STUBSIZE);
filehdr_dst->f_flags |= F_GO32STUB;
}
static void
adjust_filehdr_out_pre (bfd * abfd, void * in, void * 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 (coff_data (abfd)->go32stub != NULL)
memcpy (filehdr_out->stub, coff_data (abfd)->go32stub, GO32_STUBSIZE);
else
/* Use the default. */
memcpy (filehdr_out->stub, stub_bytes, GO32_STUBSIZE);
ADJUST_VAL (filehdr_in->f_symptr, -GO32_STUBSIZE);
}
static void
adjust_filehdr_out_post (bfd * abfd ATTRIBUTE_UNUSED,
void * in,
void * out ATTRIBUTE_UNUSED)
{
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
/* Undo the above change. */
ADJUST_VAL (filehdr_in->f_symptr, GO32_STUBSIZE);
}
static void
adjust_scnhdr_in_post (bfd * abfd ATTRIBUTE_UNUSED,
void * ext ATTRIBUTE_UNUSED,
void * in)
{
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
ADJUST_VAL (scnhdr_int->s_scnptr, GO32_STUBSIZE);
ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE);
ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_STUBSIZE);
}
static void
adjust_scnhdr_out_pre (bfd * abfd ATTRIBUTE_UNUSED,
void * in,
void * out ATTRIBUTE_UNUSED)
{
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
ADJUST_VAL (scnhdr_int->s_scnptr, -GO32_STUBSIZE);
ADJUST_VAL (scnhdr_int->s_relptr, -GO32_STUBSIZE);
ADJUST_VAL (scnhdr_int->s_lnnoptr, -GO32_STUBSIZE);
}
static void
adjust_scnhdr_out_post (bfd * abfd ATTRIBUTE_UNUSED,
void * in,
void * out ATTRIBUTE_UNUSED)
{
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
ADJUST_VAL (scnhdr_int->s_scnptr, GO32_STUBSIZE);
ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE);
ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_STUBSIZE);
}
static void
adjust_aux_in_post (bfd * abfd ATTRIBUTE_UNUSED,
void * ext1 ATTRIBUTE_UNUSED,
int type,
int in_class,
int indx ATTRIBUTE_UNUSED,
int numaux ATTRIBUTE_UNUSED,
void * in1)
{
union internal_auxent *in = (union internal_auxent *) in1;
if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
|| ISTAG (in_class))
{
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE);
}
}
static void
adjust_aux_out_pre (bfd *abfd ATTRIBUTE_UNUSED,
void * inp,
int type,
int in_class,
int indx ATTRIBUTE_UNUSED,
int numaux ATTRIBUTE_UNUSED,
void * extp ATTRIBUTE_UNUSED)
{
union internal_auxent *in = (union internal_auxent *) inp;
if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
|| ISTAG (in_class))
{
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -GO32_STUBSIZE);
}
}
static void
adjust_aux_out_post (bfd *abfd ATTRIBUTE_UNUSED,
void * inp,
int type,
int in_class,
int indx ATTRIBUTE_UNUSED,
int numaux ATTRIBUTE_UNUSED,
void * extp ATTRIBUTE_UNUSED)
{
union internal_auxent *in = (union internal_auxent *) inp;
if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
|| ISTAG (in_class))
{
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_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 (bfd *abfd)
{
/* Do it only once. */
if (coff_data (abfd)->go32stub == 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). */
coff_data (abfd)->go32stub = bfd_alloc (abfd, (bfd_size_type) coff_start);
if (coff_data (abfd)->go32stub == NULL)
{
close (f);
return;
}
lseek (f, 0L, SEEK_SET);
if ((unsigned long) read (f, coff_data (abfd)->go32stub, coff_start)
!= coff_start)
{
bfd_release (abfd, coff_data (abfd)->go32stub);
coff_data (abfd)->go32stub = NULL;
}
close (f);
}
stub_end:
/* There was something wrong above, so use now the standard builtin
stub. */
if (coff_data (abfd)->go32stub == NULL)
{
coff_data (abfd)->go32stub
= bfd_alloc (abfd, (bfd_size_type) GO32_STUBSIZE);
if (coff_data (abfd)->go32stub == NULL)
return;
memcpy (coff_data (abfd)->go32stub, stub_bytes, GO32_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 (bfd *ibfd, bfd *obfd)
{
/* Check if both are the same targets. */
if (ibfd->xvec != obfd->xvec)
return TRUE;
/* Check if we have a source stub. */
if (coff_data (ibfd)->go32stub == NULL)
return TRUE;
/* As adjust_filehdr_out_pre may get called only after this function,
optionally allocate the output stub. */
if (coff_data (obfd)->go32stub == NULL)
coff_data (obfd)->go32stub = bfd_alloc (obfd,
(bfd_size_type) GO32_STUBSIZE);
/* Now copy the stub. */
if (coff_data (obfd)->go32stub != NULL)
memcpy (coff_data (obfd)->go32stub, coff_data (ibfd)->go32stub,
GO32_STUBSIZE);
return TRUE;
}
/* coff_object_p only checks 2 bytes F_MAGIC at GO32_STUBSIZE inside the file
which is too fragile. */
static const bfd_target *
go32_check_format (bfd *abfd)
{
char mz[2];
if (bfd_bread (mz, 2, abfd) != 2 || mz[0] != 'M' || mz[1] != 'Z')
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
if (bfd_seek (abfd, 0, SEEK_SET) != 0)
return NULL;
return coff_object_p (abfd);
}

234
bfd/coff-tic30.c Normal file
View File

@ -0,0 +1,234 @@
/* BFD back-end for TMS320C30 coff binaries.
Copyright (C) 1998-2019 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"
#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. */
static reloc_howto_type *
tic30_coff_reloc_type_lookup (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 (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 (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:
internal->howto = NULL;
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 (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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
_bfd_dummy_target
},
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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
bfd/coff-tic4x.c Normal file
View File

@ -0,0 +1,292 @@
/* BFD back-end for TMS320C4X coff binaries.
Copyright (C) 1996-2019 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 reloc_howto_type *
coff_tic4x_rtype_to_howto (bfd *, asection *, struct internal_reloc *,
struct coff_link_hash_entry *,
struct internal_syment *, bfd_vma *);
static void
tic4x_reloc_processing (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 (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 (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry,
asymbol *symbol ATTRIBUTE_UNUSED,
void * 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 (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 (bfd *abfd,
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 (_("%pB: unsupported relocation type %#x"),
abfd, (unsigned int) dst->r_type);
abort();
}
static reloc_howto_type *
coff_tic4x_rtype_to_howto (bfd *abfd,
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 (abfd, &genrel, rel);
return genrel.howto;
}
static void
tic4x_reloc_processing (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
/* xgettext: c-format */
(_("%pB: 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. */
tic4x_lookup_howto (abfd, relent, reloc);
}
/* TI COFF v0, DOS tools (little-endian headers). */
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff0_vec, "coff0-tic4x",
0, SEC_CODE | SEC_READONLY, '_',
NULL, &ticoff0_swap_table);
/* TI COFF v0, SPARC tools (big-endian headers). */
CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff0_beh_vec, "coff0-beh-tic4x",
0, SEC_CODE | SEC_READONLY, '_',
&tic4x_coff0_vec, &ticoff0_swap_table);
/* TI COFF v1, DOS tools (little-endian headers). */
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff1_vec, "coff1-tic4x",
0, SEC_CODE | SEC_READONLY, '_',
&tic4x_coff0_beh_vec, &ticoff1_swap_table);
/* TI COFF v1, SPARC tools (big-endian headers). */
CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff1_beh_vec, "coff1-beh-tic4x",
0, SEC_CODE | SEC_READONLY, '_',
&tic4x_coff1_vec, &ticoff1_swap_table);
/* TI COFF v2, TI DOS tools output (little-endian headers). */
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff2_vec, "coff2-tic4x",
0, SEC_CODE | SEC_READONLY, '_',
&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",
0, SEC_CODE | SEC_READONLY, '_',
&tic4x_coff2_vec, COFF_SWAP_TABLE);

746
bfd/coff-tic54x.c Normal file
View File

@ -0,0 +1,746 @@
/* BFD back-end for TMS320C54X coff binaries.
Copyright (C) 1999-2019 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 (arelent *, struct internal_reloc *,
asymbol **, bfd *, asection *);
/* 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
static void
bfd_ticoff_set_section_load_page (asection *sect,
int page)
{
sect->lma = (sect->lma & ADDR_MASK) | PG_TO_FLAG(page);
}
static int
bfd_ticoff_get_section_load_page (asection *sect)
{
int page;
/* Provide meaningful defaults for predefined sections. */
if (sect == bfd_com_section_ptr)
page = PG_DATA;
else if (bfd_is_und_section (sect)
|| bfd_is_abs_section (sect)
|| bfd_is_ind_section (sect))
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 (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 (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry,
asymbol *symbol ATTRIBUTE_UNUSED,
void * 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. */
static reloc_howto_type *
tic54x_coff_reloc_type_lookup (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 (bfd *abfd,
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 (_("%pB: unsupported relocation type %#x"),
abfd, (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 (bfd *abfd,
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 (abfd, &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 (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
/* 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 (bfd *abfd,
sec_ptr section,
const void * 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 (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
/* xgettext: c-format */
(_("%pB: 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 (abfd, 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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
_bfd_dummy_target
},
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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,
&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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
_bfd_dummy_target
},
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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,
&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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
_bfd_dummy_target
},
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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,
&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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
_bfd_dummy_target
},
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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,
&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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
_bfd_dummy_target
},
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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 */
0, /* match priority. */
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_check_format */
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
_bfd_dummy_target
},
{ /* bfd_set_format */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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
};

711
bfd/coff-tic80.c Normal file
View File

@ -0,0 +1,711 @@
/* BFD back-end for Texas Instruments TMS320C80 Multimedia Video Processor (MVP).
Copyright (C) 1996-2019 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 COFF_ENCODE_ALIGNMENT(S,X) ((S).s_flags |= (((unsigned)(X) & 0xf) << 8))
#define COFF_DECODE_ALIGNMENT(X) (((X) >> 8) & 0xf)
#define GET_SCNHDR_FLAGS H_GET_16
#define PUT_SCNHDR_FLAGS H_PUT_16
static bfd_reloc_status_type ppbase_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type glob15_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type glob16_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type local16_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
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 (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry ATTRIBUTE_UNUSED,
asymbol *symbol_in ATTRIBUTE_UNUSED,
void * 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 (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry ATTRIBUTE_UNUSED,
asymbol *symbol_in ATTRIBUTE_UNUSED,
void * 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 (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry ATTRIBUTE_UNUSED,
asymbol *symbol_in ATTRIBUTE_UNUSED,
void * 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 (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry ATTRIBUTE_UNUSED,
asymbol *symbol_in ATTRIBUTE_UNUSED,
void * 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 (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 (_("unsupported relocation type %#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 (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 (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 (! bfd_link_relocatable (info))
(*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd, input_section,
rel->r_vaddr - input_section->vma, TRUE);
}
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
/* xgettext: c-format */
(_("%pB: bad reloc address %#" PRIx64 " in section `%pA'"),
input_bfd, (uint64_t) rel->r_vaddr, input_section);
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;
}
(*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 TRUE;
}
#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 (tic80_coff_vec, "coff-tic80", D_PAGED, 0, '_', NULL, COFF_SWAP_TABLE)

826
bfd/coff-x86_64.c Normal file
View File

@ -0,0 +1,826 @@
/* BFD back-end for AMD 64 COFF files.
Copyright (C) 2006-2019 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
/* Note we have to make sure not to include headers twice.
Not all headers are wrapped in #ifdef guards, so we define
PEI_HEADERS to prevent double including here. */
#ifndef PEI_HEADERS
#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"
#endif
#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
/* All users of this file have bfd_octets_per_byte (abfd, sec) == 1. */
#define OCTETS_PER_BYTE(ABFD, SEC) 1
/* 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;
bfd_size_type octets = (reloc_entry->address
* OCTETS_PER_BYTE (abfd, input_section));
unsigned char *addr = (unsigned char *) data + octets;
if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octets))
return bfd_reloc_outofrange;
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:
{
bfd_uint64_t x = bfd_get_64 (abfd, addr);
DOIT (x);
bfd_put_64 (abfd, x, addr);
}
break;
default:
bfd_set_error (bfd_error_bad_value);
return bfd_reloc_notsupported;
}
}
/* 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
&& howto->type != R_AMD64_SECREL;
}
#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 */
};
#define NUM_HOWTOS ARRAY_SIZE (howto_table)
/* 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 < NUM_HOWTOS) \
? 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 (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 && reloc.r_type < NUM_HOWTOS \
&& 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 (bfd_link_relocatable (info))
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 >= NUM_HOWTOS)
{
bfd_set_error (bfd_error_bad_value);
return NULL;
}
howto = howto_table + rel->r_type;
#if defined(COFF_WITH_PE)
/* Cancel out code in _bfd_coff_generic_relocate_section. */
*addendp = 0;
if (rel->r_type >= R_AMD64_PCRLONG_1 && rel->r_type <= R_AMD64_PCRLONG_5)
{
*addendp -= (bfd_vma)(rel->r_type - R_AMD64_PCRLONG);
rel->r_type = R_AMD64_PCRLONG;
}
#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)
{
#ifndef DONT_EXTEND_AMD64
if (rel->r_type == R_AMD64_PCRQUAD)
*addendp -= 8;
else
#endif
*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->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak))
osect_vma = h->root.u.def.section->output_section->vma;
else
{
asection *s;
int i;
/* Sigh, the only way to get the section to offset against
is to find it the hard way. */
for (s = abfd->sections, i = 1; i < sym->n_scnum; i++)
s = s->next;
osect_vma = s->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 < NUM_HOWTOS; 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_64_coff_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 | BFD_COMPRESS | BFD_DECOMPRESS),
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags. */
#if defined(COFF_WITH_PE)
| SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
#endif
| SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
#ifdef TARGET_UNDERSCORE
TARGET_UNDERSCORE, /* Leading underscore. */
#else
0, /* Leading underscore. */
#endif
'/', /* Ar_pad_char. */
15, /* Ar_max_namelen. */
0, /* match priority. */
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_check_format. */
_bfd_dummy_target,
amd64coff_object_p,
bfd_generic_archive_p,
amd64coff_object_p
},
{ /* bfd_set_format. */
_bfd_bool_bfd_false_error,
coff_mkobject,
_bfd_generic_mkarchive,
_bfd_bool_bfd_false_error
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
coff_write_object_contents,
_bfd_write_archive_contents,
_bfd_bool_bfd_false_error
},
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
};

283
bfd/coff-z80.c Normal file
View File

@ -0,0 +1,283 @@
/* BFD back-end for Zilog Z80 COFF binaries.
Copyright (C) 2005-2019 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, 2, 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:
internal->howto = NULL;
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. */
(*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);
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)
(*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);
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 (z80_coff_vec, "coff-z80", 0,
SEC_CODE | SEC_DATA, '\0', NULL,
COFF_SWAP_TABLE)

375
bfd/coff-z8k.c Normal file
View File

@ -0,0 +1,375 @@
/* BFD back-end for Zilog Z800n COFF binaries.
Copyright (C) 1992-2019 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:
internal->howto = NULL;
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 > 127 || gap < -128)
(*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);
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)
(*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);
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)
(*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);
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)
(*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);
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 (z8k_coff_vec, "coff-z8k", 0, 0, '_', NULL, COFF_SWAP_TABLE)

3062
bfd/coff64-rs6000.c Normal file

File diff suppressed because it is too large Load Diff

5958
bfd/coffcode.h Normal file

File diff suppressed because it is too large Load Diff

3163
bfd/coffgen.c Normal file

File diff suppressed because it is too large Load Diff

3159
bfd/cofflink.c Normal file

File diff suppressed because it is too large Load Diff

814
bfd/coffswap.h Normal file
View File

@ -0,0 +1,814 @@
/* Generic COFF swapping routines, for BFD.
Copyright (C) 1990-2019 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 = (short) 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 in_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, in_class, indx, numaux, in1);
#endif
switch (in_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 (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
|| ISTAG (in_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, in_class, indx, numaux, in1);
#endif
}
static unsigned int
coff_swap_aux_out (bfd * abfd,
void * inp,
int type,
int in_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, in_class, indx, numaux, extp);
#endif
memset (ext, 0, AUXESZ);
switch (in_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 (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type)
|| ISTAG (in_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, in_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 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 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 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 (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
/* xgettext:c-format */
(_("%pB: warning: %s: line number overflow: 0x%lx > 0xffff"),
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';
/* xgettext:c-format */
_bfd_error_handler (_("%pB: %s: reloc overflow: 0x%lx > 0xffff"),
abfd, buf, scnhdr_int->s_nreloc);
bfd_set_error (bfd_error_file_truncated);
PUT_SCNHDR_NRELOC (abfd, 0xffff, scnhdr_ext->s_nreloc);
ret = 0;
}
#ifdef COFF_ADJUST_SCNHDR_OUT_POST
COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
#endif
return ret;
}

646
bfd/compress.c Normal file
View File

@ -0,0 +1,646 @@
/* Compressed section support (intended for debug sections).
Copyright (C) 2008-2019 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 <zlib.h>
#include "bfd.h"
#include "libbfd.h"
#include "safe-ctype.h"
#define MAX_COMPRESSION_HEADER_SIZE 24
static bfd_boolean
decompress_contents (bfd_byte *compressed_buffer,
bfd_size_type compressed_size,
bfd_byte *uncompressed_buffer,
bfd_size_type uncompressed_size)
{
z_stream strm;
int rc;
/* It is possible the section consists of several compressed
buffers concatenated together, so we uncompress in a loop. */
/* PR 18313: The state field in the z_stream structure is supposed
to be invisible to the user (ie us), but some compilers will
still complain about it being used without initialisation. So
we first zero the entire z_stream structure and then set the fields
that we need. */
memset (& strm, 0, sizeof strm);
strm.avail_in = compressed_size;
strm.next_in = (Bytef*) compressed_buffer;
strm.avail_out = uncompressed_size;
BFD_ASSERT (Z_OK == 0);
rc = inflateInit (&strm);
while (strm.avail_in > 0 && strm.avail_out > 0)
{
if (rc != Z_OK)
break;
strm.next_out = ((Bytef*) uncompressed_buffer
+ (uncompressed_size - strm.avail_out));
rc = inflate (&strm, Z_FINISH);
if (rc != Z_STREAM_END)
break;
rc = inflateReset (&strm);
}
rc |= inflateEnd (&strm);
return rc == Z_OK && strm.avail_out == 0;
}
/* Compress data of the size specified in @var{uncompressed_size}
and pointed to by @var{uncompressed_buffer} using zlib and store
as the contents field. This function assumes the contents
field was allocated using bfd_malloc() or equivalent.
Return the uncompressed size if the full section contents is
compressed successfully. Otherwise return 0. */
static bfd_size_type
bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
bfd_byte *uncompressed_buffer,
bfd_size_type uncompressed_size)
{
uLong compressed_size;
bfd_byte *buffer;
bfd_size_type buffer_size;
bfd_boolean decompress;
int zlib_size = 0;
int orig_compression_header_size;
bfd_size_type orig_uncompressed_size;
unsigned int orig_uncompressed_alignment_pow;
int header_size = bfd_get_compression_header_size (abfd, NULL);
bfd_boolean compressed
= bfd_is_section_compressed_with_header (abfd, sec,
&orig_compression_header_size,
&orig_uncompressed_size,
&orig_uncompressed_alignment_pow);
/* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size,
overhead in .zdebug* section. */
if (!header_size)
header_size = 12;
if (compressed)
{
/* We shouldn't decompress unsupported compressed section. */
if (orig_compression_header_size < 0)
abort ();
/* Different compression schemes. Just move the compressed section
contents to the right position. */
if (orig_compression_header_size == 0)
{
/* Convert it from .zdebug* section. Get the uncompressed
size first. We need to subtract the 12-byte overhead in
.zdebug* section. Set orig_compression_header_size to
the 12-bye overhead. */
orig_compression_header_size = 12;
zlib_size = uncompressed_size - 12;
}
else
{
/* Convert it to .zdebug* section. */
zlib_size = uncompressed_size - orig_compression_header_size;
}
/* Add the header size. */
compressed_size = zlib_size + header_size;
}
else
compressed_size = compressBound (uncompressed_size) + header_size;
/* Uncompress if it leads to smaller size. */
if (compressed && compressed_size > orig_uncompressed_size)
{
decompress = TRUE;
buffer_size = orig_uncompressed_size;
}
else
{
decompress = FALSE;
buffer_size = compressed_size;
}
buffer = (bfd_byte *) bfd_alloc (abfd, buffer_size);
if (buffer == NULL)
return 0;
if (compressed)
{
sec->size = orig_uncompressed_size;
if (decompress)
{
if (!decompress_contents (uncompressed_buffer
+ orig_compression_header_size,
zlib_size, buffer, buffer_size))
{
bfd_set_error (bfd_error_bad_value);
bfd_release (abfd, buffer);
return 0;
}
free (uncompressed_buffer);
bfd_set_section_alignment (sec, orig_uncompressed_alignment_pow);
sec->contents = buffer;
sec->compress_status = COMPRESS_SECTION_DONE;
return orig_uncompressed_size;
}
else
{
bfd_update_compression_header (abfd, buffer, sec);
memmove (buffer + header_size,
uncompressed_buffer + orig_compression_header_size,
zlib_size);
}
}
else
{
if (compress ((Bytef*) buffer + header_size,
&compressed_size,
(const Bytef*) uncompressed_buffer,
uncompressed_size) != Z_OK)
{
bfd_release (abfd, buffer);
bfd_set_error (bfd_error_bad_value);
return 0;
}
compressed_size += header_size;
/* PR binutils/18087: If compression didn't make the section smaller,
just keep it uncompressed. */
if (compressed_size < uncompressed_size)
bfd_update_compression_header (abfd, buffer, sec);
else
{
/* NOTE: There is a small memory leak here since
uncompressed_buffer is malloced and won't be freed. */
bfd_release (abfd, buffer);
sec->contents = uncompressed_buffer;
sec->compress_status = COMPRESS_SECTION_NONE;
return uncompressed_size;
}
}
free (uncompressed_buffer);
sec->contents = buffer;
sec->size = compressed_size;
sec->compress_status = COMPRESS_SECTION_DONE;
return uncompressed_size;
}
/*
FUNCTION
bfd_get_full_section_contents
SYNOPSIS
bfd_boolean bfd_get_full_section_contents
(bfd *abfd, asection *section, bfd_byte **ptr);
DESCRIPTION
Read all data from @var{section} in BFD @var{abfd}, decompress
if needed, and store in @var{*ptr}. If @var{*ptr} is NULL,
return @var{*ptr} with memory malloc'd by this function.
Return @code{TRUE} if the full section contents is retrieved
successfully. If the section has no contents then this function
returns @code{TRUE} but @var{*ptr} is set to NULL.
*/
bfd_boolean
bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
{
bfd_size_type sz;
bfd_byte *p = *ptr;
bfd_boolean ret;
bfd_size_type save_size;
bfd_size_type save_rawsize;
bfd_byte *compressed_buffer;
unsigned int compression_header_size;
if (abfd->direction != write_direction && sec->rawsize != 0)
sz = sec->rawsize;
else
sz = sec->size;
if (sz == 0)
{
*ptr = NULL;
return TRUE;
}
switch (sec->compress_status)
{
case COMPRESS_SECTION_NONE:
if (p == NULL)
{
ufile_ptr filesize = bfd_get_file_size (abfd);
if (filesize > 0
&& filesize < sz
/* PR 24753: Linker created sections can be larger than
the file size, eg if they are being used to hold stubs. */
&& (bfd_section_flags (sec) & SEC_LINKER_CREATED) == 0
/* The MMO file format supports its own special compression
technique, but it uses COMPRESS_SECTION_NONE when loading
a section's contents. */
&& bfd_get_flavour (abfd) != bfd_target_mmo_flavour)
{
/* PR 24708: Avoid attempts to allocate a ridiculous amount
of memory. */
bfd_set_error (bfd_error_no_memory);
_bfd_error_handler
/* xgettext:c-format */
(_("error: %pB(%pA) section size (%#" PRIx64 " bytes) is larger than file size (%#" PRIx64 " bytes)"),
abfd, sec, (uint64_t) sz, (uint64_t) filesize);
return FALSE;
}
p = (bfd_byte *) bfd_malloc (sz);
if (p == NULL)
{
/* PR 20801: Provide a more helpful error message. */
if (bfd_get_error () == bfd_error_no_memory)
_bfd_error_handler
/* xgettext:c-format */
(_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"),
abfd, sec, (uint64_t) sz);
return FALSE;
}
}
if (!bfd_get_section_contents (abfd, sec, p, 0, sz))
{
if (*ptr != p)
free (p);
return FALSE;
}
*ptr = p;
return TRUE;
case DECOMPRESS_SECTION_SIZED:
/* Read in the full compressed section contents. */
compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size);
if (compressed_buffer == NULL)
return FALSE;
save_rawsize = sec->rawsize;
save_size = sec->size;
/* Clear rawsize, set size to compressed size and set compress_status
to COMPRESS_SECTION_NONE. If the compressed size is bigger than
the uncompressed size, bfd_get_section_contents will fail. */
sec->rawsize = 0;
sec->size = sec->compressed_size;
sec->compress_status = COMPRESS_SECTION_NONE;
ret = bfd_get_section_contents (abfd, sec, compressed_buffer,
0, sec->compressed_size);
/* Restore rawsize and size. */
sec->rawsize = save_rawsize;
sec->size = save_size;
sec->compress_status = DECOMPRESS_SECTION_SIZED;
if (!ret)
goto fail_compressed;
if (p == NULL)
p = (bfd_byte *) bfd_malloc (sz);
if (p == NULL)
goto fail_compressed;
compression_header_size = bfd_get_compression_header_size (abfd, sec);
if (compression_header_size == 0)
/* Set header size to the zlib header size if it is a
SHF_COMPRESSED section. */
compression_header_size = 12;
if (!decompress_contents (compressed_buffer + compression_header_size,
sec->compressed_size - compression_header_size, p, sz))
{
bfd_set_error (bfd_error_bad_value);
if (p != *ptr)
free (p);
fail_compressed:
free (compressed_buffer);
return FALSE;
}
free (compressed_buffer);
*ptr = p;
return TRUE;
case COMPRESS_SECTION_DONE:
if (sec->contents == NULL)
return FALSE;
if (p == NULL)
{
p = (bfd_byte *) bfd_malloc (sz);
if (p == NULL)
return FALSE;
*ptr = p;
}
/* PR 17512; file: 5bc29788. */
if (p != sec->contents)
memcpy (p, sec->contents, sz);
return TRUE;
default:
abort ();
}
}
/*
FUNCTION
bfd_cache_section_contents
SYNOPSIS
void bfd_cache_section_contents
(asection *sec, void *contents);
DESCRIPTION
Stash @var(contents) so any following reads of @var(sec) do
not need to decompress again.
*/
void
bfd_cache_section_contents (asection *sec, void *contents)
{
if (sec->compress_status == DECOMPRESS_SECTION_SIZED)
sec->compress_status = COMPRESS_SECTION_DONE;
sec->contents = contents;
sec->flags |= SEC_IN_MEMORY;
}
/*
FUNCTION
bfd_is_section_compressed_with_header
SYNOPSIS
bfd_boolean bfd_is_section_compressed_with_header
(bfd *abfd, asection *section,
int *compression_header_size_p,
bfd_size_type *uncompressed_size_p,
unsigned int *uncompressed_alignment_power_p);
DESCRIPTION
Return @code{TRUE} if @var{section} is compressed. Compression
header size is returned in @var{compression_header_size_p},
uncompressed size is returned in @var{uncompressed_size_p}
and the uncompressed data alignement power is returned in
@var{uncompressed_align_pow_p}. If compression is
unsupported, compression header size is returned with -1
and uncompressed size is returned with 0.
*/
bfd_boolean
bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec,
int *compression_header_size_p,
bfd_size_type *uncompressed_size_p,
unsigned int *uncompressed_align_pow_p)
{
bfd_byte header[MAX_COMPRESSION_HEADER_SIZE];
int compression_header_size;
int header_size;
unsigned int saved = sec->compress_status;
bfd_boolean compressed;
*uncompressed_align_pow_p = 0;
compression_header_size = bfd_get_compression_header_size (abfd, sec);
if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
abort ();
header_size = compression_header_size ? compression_header_size : 12;
/* Don't decompress the section. */
sec->compress_status = COMPRESS_SECTION_NONE;
/* Read the header. */
if (bfd_get_section_contents (abfd, sec, header, 0, header_size))
{
if (compression_header_size == 0)
/* In this case, it should be "ZLIB" followed by the uncompressed
section size, 8 bytes in big-endian order. */
compressed = CONST_STRNEQ ((char*) header , "ZLIB");
else
compressed = TRUE;
}
else
compressed = FALSE;
*uncompressed_size_p = sec->size;
if (compressed)
{
if (compression_header_size != 0)
{
if (!bfd_check_compression_header (abfd, header, sec,
uncompressed_size_p,
uncompressed_align_pow_p))
compression_header_size = -1;
}
/* Check for the pathalogical case of a debug string section that
contains the string ZLIB.... as the first entry. We assume that
no uncompressed .debug_str section would ever be big enough to
have the first byte of its (big-endian) size be non-zero. */
else if (strcmp (sec->name, ".debug_str") == 0
&& ISPRINT (header[4]))
compressed = FALSE;
else
*uncompressed_size_p = bfd_getb64 (header + 4);
}
/* Restore compress_status. */
sec->compress_status = saved;
*compression_header_size_p = compression_header_size;
return compressed;
}
/*
FUNCTION
bfd_is_section_compressed
SYNOPSIS
bfd_boolean bfd_is_section_compressed
(bfd *abfd, asection *section);
DESCRIPTION
Return @code{TRUE} if @var{section} is compressed.
*/
bfd_boolean
bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
{
int compression_header_size;
bfd_size_type uncompressed_size;
unsigned int uncompressed_align_power;
return (bfd_is_section_compressed_with_header (abfd, sec,
&compression_header_size,
&uncompressed_size,
&uncompressed_align_power)
&& compression_header_size >= 0
&& uncompressed_size > 0);
}
/*
FUNCTION
bfd_init_section_decompress_status
SYNOPSIS
bfd_boolean bfd_init_section_decompress_status
(bfd *abfd, asection *section);
DESCRIPTION
Record compressed section size, update section size with
decompressed size and set compress_status to
DECOMPRESS_SECTION_SIZED.
Return @code{FALSE} if the section is not a valid compressed
section. Otherwise, return @code{TRUE}.
*/
bfd_boolean
bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
{
bfd_byte header[MAX_COMPRESSION_HEADER_SIZE];
int compression_header_size;
int header_size;
bfd_size_type uncompressed_size;
unsigned int uncompressed_alignment_power = 0;
compression_header_size = bfd_get_compression_header_size (abfd, sec);
if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
abort ();
header_size = compression_header_size ? compression_header_size : 12;
/* Read the header. */
if (sec->rawsize != 0
|| sec->contents != NULL
|| sec->compress_status != COMPRESS_SECTION_NONE
|| !bfd_get_section_contents (abfd, sec, header, 0, header_size))
{
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
if (compression_header_size == 0)
{
/* In this case, it should be "ZLIB" followed by the uncompressed
section size, 8 bytes in big-endian order. */
if (! CONST_STRNEQ ((char*) header, "ZLIB"))
{
bfd_set_error (bfd_error_wrong_format);
return FALSE;
}
uncompressed_size = bfd_getb64 (header + 4);
}
else if (!bfd_check_compression_header (abfd, header, sec,
&uncompressed_size,
&uncompressed_alignment_power))
{
bfd_set_error (bfd_error_wrong_format);
return FALSE;
}
sec->compressed_size = sec->size;
sec->size = uncompressed_size;
bfd_set_section_alignment (sec, uncompressed_alignment_power);
sec->compress_status = DECOMPRESS_SECTION_SIZED;
return TRUE;
}
/*
FUNCTION
bfd_init_section_compress_status
SYNOPSIS
bfd_boolean bfd_init_section_compress_status
(bfd *abfd, asection *section);
DESCRIPTION
If open for read, compress section, update section size with
compressed size and set compress_status to COMPRESS_SECTION_DONE.
Return @code{FALSE} if the section is not a valid compressed
section. Otherwise, return @code{TRUE}.
*/
bfd_boolean
bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
{
bfd_size_type uncompressed_size;
bfd_byte *uncompressed_buffer;
/* Error if not opened for read. */
if (abfd->direction != read_direction
|| sec->size == 0
|| sec->rawsize != 0
|| sec->contents != NULL
|| sec->compress_status != COMPRESS_SECTION_NONE)
{
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
/* Read in the full section contents and compress it. */
uncompressed_size = sec->size;
uncompressed_buffer = (bfd_byte *) bfd_malloc (uncompressed_size);
/* PR 21431 */
if (uncompressed_buffer == NULL)
return FALSE;
if (!bfd_get_section_contents (abfd, sec, uncompressed_buffer,
0, uncompressed_size))
return FALSE;
uncompressed_size = bfd_compress_section_contents (abfd, sec,
uncompressed_buffer,
uncompressed_size);
return uncompressed_size != 0;
}
/*
FUNCTION
bfd_compress_section
SYNOPSIS
bfd_boolean bfd_compress_section
(bfd *abfd, asection *section, bfd_byte *uncompressed_buffer);
DESCRIPTION
If open for write, compress section, update section size with
compressed size and set compress_status to COMPRESS_SECTION_DONE.
Return @code{FALSE} if compression fail. Otherwise, return
@code{TRUE}.
*/
bfd_boolean
bfd_compress_section (bfd *abfd, sec_ptr sec, bfd_byte *uncompressed_buffer)
{
bfd_size_type uncompressed_size = sec->size;
/* Error if not opened for write. */
if (abfd->direction != write_direction
|| uncompressed_size == 0
|| uncompressed_buffer == NULL
|| sec->contents != NULL
|| sec->compressed_size != 0
|| sec->compress_status != COMPRESS_SECTION_NONE)
{
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
/* Compress it. */
return bfd_compress_section_contents (abfd, sec, uncompressed_buffer,
uncompressed_size) != 0;
}

1481
bfd/config.bfd Normal file

File diff suppressed because it is too large Load Diff

418
bfd/config.in Normal file
View File

@ -0,0 +1,418 @@
/* config.in. Generated from configure.ac by autoheader. */
/* Check that config.h is #included before system headers
(this works only for glibc, but that should be enough). */
#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
# error config.h must be #included before system headers
#endif
#define __CONFIG_H__ 1
/* Name of host specific core header file to include in elf.c. */
#undef CORE_HEADER
/* Define to 1 if you want to enable -z separate-code in ELF linker by
default. */
#undef DEFAULT_LD_Z_SEPARATE_CODE
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
/* Define to 1 if you have the <alloca.h> header file. */
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the declaration of `asprintf', and to 0 if you
don't. */
#undef HAVE_DECL_ASPRINTF
/* Define to 1 if you have the declaration of `basename', and to 0 if you
don't. */
#undef HAVE_DECL_BASENAME
/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
#undef HAVE_DECL_FFS
/* Define to 1 if you have the declaration of `free', and to 0 if you don't.
*/
#undef HAVE_DECL_FREE
/* Define to 1 if you have the declaration of `fseeko', and to 0 if you don't.
*/
#undef HAVE_DECL_FSEEKO
/* Define to 1 if you have the declaration of `fseeko64', and to 0 if you
don't. */
#undef HAVE_DECL_FSEEKO64
/* Define to 1 if you have the declaration of `ftello', and to 0 if you don't.
*/
#undef HAVE_DECL_FTELLO
/* Define to 1 if you have the declaration of `ftello64', and to 0 if you
don't. */
#undef HAVE_DECL_FTELLO64
/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't.
*/
#undef HAVE_DECL_GETENV
/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't.
*/
#undef HAVE_DECL_MALLOC
/* Define to 1 if you have the declaration of `realloc', and to 0 if you
don't. */
#undef HAVE_DECL_REALLOC
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#undef HAVE_DECL_SNPRINTF
/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
*/
#undef HAVE_DECL_STPCPY
/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
don't. */
#undef HAVE_DECL_STRNLEN
/* Define to 1 if you have the declaration of `strstr', and to 0 if you don't.
*/
#undef HAVE_DECL_STRSTR
/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
don't. */
#undef HAVE_DECL_VASPRINTF
/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
don't. */
#undef HAVE_DECL_VSNPRINTF
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `fcntl' function. */
#undef HAVE_FCNTL
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fdopen' function. */
#undef HAVE_FDOPEN
/* Define to 1 if you have the `fileno' function. */
#undef HAVE_FILENO
/* Define to 1 if you have the `fls' function. */
#undef HAVE_FLS
/* Define to 1 if you have the `fopen64' function. */
#undef HAVE_FOPEN64
/* Define to 1 if you have the `fseeko' function. */
#undef HAVE_FSEEKO
/* Define to 1 if you have the `fseeko64' function. */
#undef HAVE_FSEEKO64
/* Define to 1 if you have the `ftello' function. */
#undef HAVE_FTELLO
/* Define to 1 if you have the `ftello64' function. */
#undef HAVE_FTELLO64
/* Define to 1 if you have the `getgid' function. */
#undef HAVE_GETGID
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define to 1 if you have the `getrlimit' function. */
#undef HAVE_GETRLIMIT
/* Define to 1 if you have the `getuid' function. */
#undef HAVE_GETUID
/* Define if your compiler supports hidden visibility. */
#undef HAVE_HIDDEN
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if the system has the type `long double'. */
#undef HAVE_LONG_DOUBLE
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
/* Define if <sys/procfs.h> has lwpstatus_t. */
#undef HAVE_LWPSTATUS_T
/* Define if <sys/procfs.h> has lwpstatus_t.pr_context. */
#undef HAVE_LWPSTATUS_T_PR_CONTEXT
/* Define if <sys/procfs.h> has lwpstatus_t.pr_fpreg. */
#undef HAVE_LWPSTATUS_T_PR_FPREG
/* Define if <sys/procfs.h> has lwpstatus_t.pr_reg. */
#undef HAVE_LWPSTATUS_T_PR_REG
/* Define if <sys/procfs.h> has lwpxstatus_t. */
#undef HAVE_LWPXSTATUS_T
/* Define to 1 if you have the `madvise' function. */
#undef HAVE_MADVISE
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the `mprotect' function. */
#undef HAVE_MPROTECT
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
/* Define if <sys/procfs.h> has prpsinfo32_t. */
#undef HAVE_PRPSINFO32_T
/* Define if <sys/procfs.h> has prpsinfo32_t.pr_pid. */
#undef HAVE_PRPSINFO32_T_PR_PID
/* Define if <sys/procfs.h> has prpsinfo_t. */
#undef HAVE_PRPSINFO_T
/* Define if <sys/procfs.h> has prpsinfo_t.pr_pid. */
#undef HAVE_PRPSINFO_T_PR_PID
/* Define if <sys/procfs.h> has prstatus32_t. */
#undef HAVE_PRSTATUS32_T
/* Define if <sys/procfs.h> has prstatus32_t.pr_who. */
#undef HAVE_PRSTATUS32_T_PR_WHO
/* Define if <sys/procfs.h> has prstatus_t. */
#undef HAVE_PRSTATUS_T
/* Define if <sys/procfs.h> has prstatus_t.pr_who. */
#undef HAVE_PRSTATUS_T_PR_WHO
/* Define if <sys/procfs.h> has psinfo32_t. */
#undef HAVE_PSINFO32_T
/* Define if <sys/procfs.h> has psinfo32_t.pr_pid. */
#undef HAVE_PSINFO32_T_PR_PID
/* Define if <sys/procfs.h> has psinfo_t. */
#undef HAVE_PSINFO_T
/* Define if <sys/procfs.h> has psinfo_t.pr_pid. */
#undef HAVE_PSINFO_T_PR_PID
/* Define if <sys/procfs.h> has pstatus32_t. */
#undef HAVE_PSTATUS32_T
/* Define if <sys/procfs.h> has pstatus_t. */
#undef HAVE_PSTATUS_T
/* Define if <sys/procfs.h> has pxstatus_t. */
#undef HAVE_PXSTATUS_T
/* Define to 1 if you have the `setitimer' function. */
#undef HAVE_SETITIMER
/* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtoull' function. */
#undef HAVE_STRTOULL
/* Define if struct core_dumpx has member c_impl */
#undef HAVE_ST_C_IMPL
/* Define to 1 if you have the `sysconf' function. */
#undef HAVE_SYSCONF
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/procfs.h> header file. */
#undef HAVE_SYS_PROCFS_H
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Define to 1 if you have the <wctype.h> header file. */
#undef HAVE_WCTYPE_H
/* Define if <sys/procfs.h> has win32_pstatus_t. */
#undef HAVE_WIN32_PSTATUS_T
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `char', as computed by sizeof. */
#undef SIZEOF_CHAR
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG
/* The size of `off_t', as computed by sizeof. */
#undef SIZEOF_OFF_T
/* The size of `short', as computed by sizeof. */
#undef SIZEOF_SHORT
/* The size of `void *', as computed by sizeof. */
#undef SIZEOF_VOID_P
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define if you can safely include both <string.h> and <strings.h>. */
#undef STRING_WITH_STRINGS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Name of host specific header file to include in trad-core.c. */
#undef TRAD_HEADER
/* Define if 64-bit archives should always be used. */
#undef USE_64_BIT_ARCHIVE
/* Use b modifier when opening binary files? */
#undef USE_BINARY_FOPEN
/* Define if we should use leading underscore on 64 bit mingw targets */
#undef USE_MINGW64_LEADING_UNDERSCORES
/* Use mmap if it's available? */
#undef USE_MMAP
/* Define if we should default to creating read-only plt entries */
#undef USE_SECUREPLT
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Version number of package */
#undef VERSION
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to 1 if on MINIX. */
#undef _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE

19302
bfd/configure vendored Executable file

File diff suppressed because it is too large Load Diff

1128
bfd/configure.ac Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More