mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
Compare commits
2 Commits
gdb-10.2-r
...
jimb-rda-n
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4c698fb22 | ||
|
|
2b10a680d7 |
20
ChangeLog
20
ChangeLog
@@ -1,3 +1,23 @@
|
||||
2004-10-26 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
* configure.in (case ${target}): Do not build fixincludes
|
||||
on platforms where it is not used.
|
||||
* configure: Regenerated.
|
||||
|
||||
2004-10-23 Daniel Jacobowitz <dan@debian.org>
|
||||
|
||||
* configure.in: Use an absolute path to install-sh.
|
||||
* configure: Regenerated.
|
||||
|
||||
2004-10-19 Andrew Cagney <cagney@gnu.org>
|
||||
|
||||
* src-release (do-djunpack, do-md5sum): Install the generated file
|
||||
directly into the proto-toplev/ directory.
|
||||
|
||||
2004-10-19 Andrew Cagney <cagney@gnu.org>
|
||||
|
||||
* src-release (GDB_SUPPORT_DIRS): Remove utils and intl.
|
||||
|
||||
2004-10-12 Kelley Cook <kcook@gcc.gnu.org>
|
||||
|
||||
* configure.in (*-*-cygwin*): Supress warning if newlib not present.
|
||||
|
||||
340
bfd/COPYING
340
bfd/COPYING
@@ -1,340 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright 1989, 1991, 1997 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 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) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
4418
bfd/ChangeLog
4418
bfd/ChangeLog
File diff suppressed because it is too large
Load Diff
9592
bfd/ChangeLog-0001
9592
bfd/ChangeLog-0001
File diff suppressed because it is too large
Load Diff
11405
bfd/ChangeLog-0203
11405
bfd/ChangeLog-0203
File diff suppressed because it is too large
Load Diff
7848
bfd/ChangeLog-9193
7848
bfd/ChangeLog-9193
File diff suppressed because it is too large
Load Diff
10043
bfd/ChangeLog-9495
10043
bfd/ChangeLog-9495
File diff suppressed because it is too large
Load Diff
6729
bfd/ChangeLog-9697
6729
bfd/ChangeLog-9697
File diff suppressed because it is too large
Load Diff
5599
bfd/ChangeLog-9899
5599
bfd/ChangeLog-9899
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
See ../binutils/MAINTAINERS
|
||||
1677
bfd/Makefile.am
1677
bfd/Makefile.am
File diff suppressed because it is too large
Load Diff
2235
bfd/Makefile.in
2235
bfd/Makefile.in
File diff suppressed because it is too large
Load Diff
83
bfd/PORTING
83
bfd/PORTING
@@ -1,83 +0,0 @@
|
||||
Preliminary Notes on Porting BFD
|
||||
--------------------------------
|
||||
|
||||
The 'host' is the system a tool runs *on*.
|
||||
The 'target' is the system a tool runs *for*, i.e.
|
||||
a tool can read/write the binaries of the target.
|
||||
|
||||
Porting to a new host
|
||||
---------------------
|
||||
Pick a name for your host. Call that <host>.
|
||||
(<host> might be sun4, ...)
|
||||
Create a file hosts/<host>.mh.
|
||||
|
||||
Porting to a new target
|
||||
-----------------------
|
||||
Pick a name for your target. Call that <target>.
|
||||
Call the name for your CPU architecture <cpu>.
|
||||
You need to create <target>.c and config/<target>.mt,
|
||||
and add a case for it to a case statements in bfd/configure.host and
|
||||
bfd/config.bfd, which associates each canonical host type with a BFD
|
||||
host type (used as the base of the makefile fragment names), and to the
|
||||
table in bfd/configure.in which associates each target vector with
|
||||
the .o files it uses.
|
||||
|
||||
config/<target>.mt is a Makefile fragment.
|
||||
The following is usually enough:
|
||||
DEFAULT_VECTOR=<target>_vec
|
||||
SELECT_ARCHITECTURES=bfd_<cpu>_arch
|
||||
|
||||
See the list of cpu types in archures.c, or "ls cpu-*.c".
|
||||
If your architecture is new, you need to add it to the tables
|
||||
in bfd/archures.c, opcodes/configure.in, and binutils/objdump.c.
|
||||
|
||||
For more information about .mt and .mh files, see config/README.
|
||||
|
||||
The file <target>.c is the hard part. It implements the
|
||||
bfd_target <target>_vec, which includes pointers to
|
||||
functions that do the actual <target>-specific methods.
|
||||
|
||||
Porting to a <target> that uses the a.out binary format
|
||||
-------------------------------------------------------
|
||||
|
||||
In this case, the include file aout-target.h probaby does most
|
||||
of what you need. The program gen-aout generates <target>.c for
|
||||
you automatically for many a.out systems. Do:
|
||||
make gen-aout
|
||||
./gen-aout <target> > <target>.c
|
||||
(This only works if you are building on the target ("native").
|
||||
If you must make a cross-port from scratch, copy the most
|
||||
similar existing file that includes aout-target.h, and fix what is wrong.)
|
||||
|
||||
Check the parameters in <target>.c, and fix anything that is wrong.
|
||||
(Also let us know about it; perhaps we can improve gen-aout.c.)
|
||||
|
||||
TARGET_IS_BIG_ENDIAN_P
|
||||
Should be defined if <target> is big-endian.
|
||||
|
||||
N_HEADER_IN_TEXT(x)
|
||||
See discussion in ../include/aout/aout64.h.
|
||||
|
||||
BYTES_IN_WORD
|
||||
Number of bytes per word. (Usually 4 but can be 8.)
|
||||
|
||||
ARCH
|
||||
Number of bits per word. (Usually 32, but can be 64.)
|
||||
|
||||
ENTRY_CAN_BE_ZERO
|
||||
Define if the extry point (start address of an
|
||||
executable program) can be 0x0.
|
||||
|
||||
TEXT_START_ADDR
|
||||
The address of the start of the text segemnt in
|
||||
virtual memory. Normally, the same as the entry point.
|
||||
|
||||
TARGET_PAGE_SIZE
|
||||
|
||||
SEGMENT_SIZE
|
||||
Usually, the same as the TARGET_PAGE_SIZE.
|
||||
Alignment needed for the data segment.
|
||||
|
||||
TARGETNAME
|
||||
The name of the target, for run-time lookups.
|
||||
Usually "a.out-<target>"
|
||||
49
bfd/README
49
bfd/README
@@ -1,49 +0,0 @@
|
||||
BFD is an object file library. It permits applications to use the
|
||||
same routines to process object files regardless of their format.
|
||||
|
||||
BFD is used by the GNU debugger, assembler, linker, and the binary
|
||||
utilities.
|
||||
|
||||
The documentation on using BFD is scanty and may be occasionally
|
||||
incorrect. Pointers to documentation problems, or an entirely
|
||||
rewritten manual, would be appreciated.
|
||||
|
||||
There is some BFD internals documentation in doc/bfdint.texi which may
|
||||
help programmers who want to modify BFD.
|
||||
|
||||
BFD is normally built as part of another package. See the build
|
||||
instructions for that package, probably in a README file in the
|
||||
appropriate directory.
|
||||
|
||||
BFD supports the following configure options:
|
||||
|
||||
--target=TARGET
|
||||
The default target for which to build the library. TARGET is
|
||||
a configuration target triplet, such as sparc-sun-solaris.
|
||||
--enable-targets=TARGET,TARGET,TARGET...
|
||||
Additional targets the library should support. To include
|
||||
support for all known targets, use --enable-targets=all.
|
||||
--enable-64-bit-bfd
|
||||
Include support for 64 bit targets. This is automatically
|
||||
turned on if you explicitly request a 64 bit target, but not
|
||||
for --enable-targets=all. This requires a compiler with a 64
|
||||
bit integer type, such as gcc.
|
||||
--enable-shared
|
||||
Build BFD as a shared library.
|
||||
--with-mmap
|
||||
Use mmap when accessing files. This is faster on some hosts,
|
||||
but slower on others. It may not work on all hosts.
|
||||
|
||||
Report bugs with BFD to bug-binutils@gnu.org.
|
||||
|
||||
Patches are encouraged. When sending patches, always send the output
|
||||
of diff -u or diff -c from the original file to the new file. Do not
|
||||
send default diff output. Do not make the diff from the new file to
|
||||
the original file. Remember that any patch must not break other
|
||||
systems. Remember that BFD must support cross compilation from any
|
||||
host to any target, so patches which use ``#ifdef HOST'' are not
|
||||
acceptable. Please also read the ``Reporting Bugs'' section of the
|
||||
gcc manual.
|
||||
|
||||
Bug reports without patches will be remembered, but they may never get
|
||||
fixed until somebody volunteers to fix them.
|
||||
25
bfd/TODO
25
bfd/TODO
@@ -1,25 +0,0 @@
|
||||
Things that still need to be done: -*- Text -*-
|
||||
|
||||
o - A source of space lossage is that all the target-dependent code
|
||||
is in a single bfd_target structure. Hence all the code for
|
||||
*writing* object files is still pulled into all the applications
|
||||
that only care about *reading* (gdb, nm, objdump), while gas has
|
||||
to carry along all the 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.
|
||||
|
||||
|
||||
|
||||
|
||||
155
bfd/acinclude.m4
155
bfd/acinclude.m4
@@ -1,155 +0,0 @@
|
||||
sinclude(../config/accross.m4)
|
||||
sinclude(../config/acx.m4)
|
||||
|
||||
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
|
||||
|
||||
dnl See whether we need a declaration for a function.
|
||||
AC_DEFUN([BFD_NEED_DECLARATION],
|
||||
[AC_MSG_CHECKING([whether $1 must be declared])
|
||||
AC_CACHE_VAL(bfd_cv_decl_needed_$1,
|
||||
[AC_TRY_COMPILE([
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif],
|
||||
[char *(*pfn) = (char *(*)) $1],
|
||||
bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
|
||||
AC_MSG_RESULT($bfd_cv_decl_needed_$1)
|
||||
if test $bfd_cv_decl_needed_$1 = yes; then
|
||||
AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
|
||||
[Define if $1 is not declared in system header files.])
|
||||
fi
|
||||
])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
|
||||
#include <sys/procfs.h>],
|
||||
[$1 avar],
|
||||
bfd_cv_have_sys_procfs_type_$1=yes,
|
||||
bfd_cv_have_sys_procfs_type_$1=no
|
||||
)])
|
||||
if test $bfd_cv_have_sys_procfs_type_$1 = yes; then
|
||||
AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z]), 1,
|
||||
[Define if <sys/procfs.h> has $1.])
|
||||
fi
|
||||
AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_$1)
|
||||
])
|
||||
|
||||
|
||||
dnl Check for existence of member $2 in type $1 in sys/procfs.h
|
||||
|
||||
AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE_MEMBER],
|
||||
[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
|
||||
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
|
||||
[AC_TRY_COMPILE([
|
||||
#define _SYSCALL32
|
||||
#include <sys/procfs.h>],
|
||||
[$1 avar; void* aref = (void*) &avar.$2],
|
||||
bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
|
||||
bfd_cv_have_sys_procfs_type_member_$1_$2=no
|
||||
)])
|
||||
if test $bfd_cv_have_sys_procfs_type_member_$1_$2 = yes; then
|
||||
AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z])[_]translit($2, [a-z], [A-Z]), 1,
|
||||
[Define if <sys/procfs.h> has $1.$2.])
|
||||
fi
|
||||
AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_member_$1_$2)
|
||||
])
|
||||
|
||||
sinclude(../libtool.m4)
|
||||
dnl The lines below arrange for aclocal not to bring libtool.m4
|
||||
dnl AM_PROG_LIBTOOL into aclocal.m4, while still arranging for automake
|
||||
dnl to add a definition of LIBTOOL to Makefile.in.
|
||||
ifelse(yes,no,[
|
||||
AC_DEFUN([AM_PROG_LIBTOOL],)
|
||||
AC_DEFUN([AM_DISABLE_SHARED],)
|
||||
AC_SUBST(LIBTOOL)
|
||||
])
|
||||
|
||||
sinclude(../gettext.m4)
|
||||
ifelse(yes,no,[
|
||||
AC_DEFUN([CY_WITH_NLS],)
|
||||
AC_SUBST(INTLLIBS)
|
||||
])
|
||||
|
||||
AC_DEFUN([AM_INSTALL_LIBBFD],
|
||||
[AC_MSG_CHECKING([whether to install libbfd])
|
||||
AC_ARG_ENABLE(install-libbfd,
|
||||
[ --enable-install-libbfd controls installation of libbfd and related headers],
|
||||
install_libbfd_p=$enableval,
|
||||
if test "${host}" = "${target}" || test "$enable_shared" = "yes"; then
|
||||
install_libbfd_p=yes
|
||||
else
|
||||
install_libbfd_p=no
|
||||
fi)
|
||||
AC_MSG_RESULT($install_libbfd_p)
|
||||
AM_CONDITIONAL(INSTALL_LIBBFD, test $install_libbfd_p = yes)
|
||||
# Need _noncanonical variables for this.
|
||||
ACX_NONCANONICAL_HOST
|
||||
ACX_NONCANONICAL_TARGET
|
||||
# libbfd.a is a host library containing target dependent code
|
||||
bfdlibdir='$(libdir)'
|
||||
bfdincludedir='$(includedir)'
|
||||
if test "${host}" != "${target}"; then
|
||||
bfdlibdir='$(exec_prefix)/$(host_noncanonical)/$(target_noncanonical)/lib'
|
||||
bfdincludedir='$(exec_prefix)/$(host_noncanonical)/$(target_noncanonical)/include'
|
||||
fi
|
||||
AC_SUBST(bfdlibdir)
|
||||
AC_SUBST(bfdincludedir)
|
||||
]
|
||||
)
|
||||
1085
bfd/aclocal.m4
vendored
1085
bfd/aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,272 +0,0 @@
|
||||
/* BFD back-end for AIX on PS/2 core files.
|
||||
This was based on trad-core.c, which was written by John Gilmore of
|
||||
Cygnus Support.
|
||||
Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2000,
|
||||
2001, 2002, 2004
|
||||
Free Software Foundation, Inc.
|
||||
Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
|
||||
Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/i386.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#if defined (_AIX) && defined (_I386)
|
||||
#define NOCHECKS /* This is for coredump.h. */
|
||||
#define _h_USER /* Avoid including user.h from coredump.h. */
|
||||
#include <uinfo.h>
|
||||
#include <sys/i386/coredump.h>
|
||||
#endif /* _AIX && _I386 */
|
||||
|
||||
/* Maybe this could work on some other i386 but I have not tried it
|
||||
* mtranle@paris - Tue Sep 24 12:49:35 1991
|
||||
*/
|
||||
|
||||
#ifndef COR_MAGIC
|
||||
# define COR_MAGIC "core"
|
||||
#endif
|
||||
|
||||
/* Need this cast because ptr is really void *. */
|
||||
#define core_hdr(bfd) \
|
||||
(((bfd->tdata.trad_core_data))->hdr)
|
||||
#define core_section(bfd,n) \
|
||||
(((bfd)->tdata.trad_core_data)->sections[n])
|
||||
#define core_regsec(bfd) \
|
||||
(((bfd)->tdata.trad_core_data)->reg_section)
|
||||
#define core_reg2sec(bfd) \
|
||||
(((bfd)->tdata.trad_core_data)->reg2_section)
|
||||
|
||||
/* These are stored in the bfd's tdata. */
|
||||
struct trad_core_struct {
|
||||
struct corehdr *hdr; /* core file header */
|
||||
asection *reg_section;
|
||||
asection *reg2_section;
|
||||
asection *sections[MAX_CORE_SEGS];
|
||||
};
|
||||
|
||||
static void swap_abort PARAMS ((void));
|
||||
|
||||
static const bfd_target *
|
||||
aix386_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int i, n;
|
||||
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||
bfd_size_type core_size = sizeof (struct corehdr);
|
||||
bfd_size_type amt;
|
||||
struct corehdr *core;
|
||||
struct mergem {
|
||||
struct trad_core_struct coredata;
|
||||
struct corehdr internal_core;
|
||||
} *mergem;
|
||||
|
||||
amt = sizeof (longbuf);
|
||||
if (bfd_bread ((PTR) longbuf, amt, abfd) != amt)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp (longbuf, COR_MAGIC, 4))
|
||||
return 0;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, 0) != 0)
|
||||
return 0;
|
||||
|
||||
amt = sizeof (struct mergem);
|
||||
mergem = (struct mergem *) bfd_zalloc (abfd, amt);
|
||||
if (mergem == NULL)
|
||||
return 0;
|
||||
|
||||
core = &mergem->internal_core;
|
||||
|
||||
if ((bfd_bread ((PTR) core, core_size, abfd)) != core_size)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
loser:
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
abfd->tdata.any = NULL;
|
||||
bfd_section_list_clear (abfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
set_tdata (abfd, &mergem->coredata);
|
||||
core_hdr (abfd) = core;
|
||||
|
||||
/* Create the sections. */
|
||||
core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
|
||||
if (core_regsec (abfd) == NULL)
|
||||
goto loser;
|
||||
|
||||
core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
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]);
|
||||
|
||||
core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2");
|
||||
if (core_reg2sec (abfd) == NULL)
|
||||
/* bfd_release frees everything allocated after it's arg. */
|
||||
goto loser;
|
||||
|
||||
core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
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 (abfd, sname);
|
||||
if (core_section (abfd, n) == NULL)
|
||||
goto loser;
|
||||
|
||||
core_section (abfd, n)->flags = flags;
|
||||
core_section (abfd, n)->size = core->cd_segs[i].cs_len;
|
||||
core_section (abfd, n)->vma = core->cd_segs[i].cs_address;
|
||||
core_section (abfd, n)->filepos = core->cd_segs[i].cs_offset;
|
||||
core_section (abfd, n)->alignment_power = 2;
|
||||
n++;
|
||||
}
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
aix386_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->cd_comm;
|
||||
}
|
||||
|
||||
static int
|
||||
aix386_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->cd_cursig;
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
aix386_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
/* FIXME: We have no way of telling at this point. */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||
|
||||
static void
|
||||
swap_abort ()
|
||||
{
|
||||
/* This way doesn't require any declaration for ANSI to fuck up. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
#define NO_GET ((bfd_vma (*) (const void *)) swap_abort)
|
||||
#define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort)
|
||||
#define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort)
|
||||
#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort)
|
||||
#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort)
|
||||
#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort)
|
||||
|
||||
const bfd_target aix386_core_vec = {
|
||||
"aix386-core",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
NO_GET64, NO_GETS64, NO_PUT64,
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT, /* data */
|
||||
NO_GET64, NO_GETS64, NO_PUT64,
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, _bfd_dummy_target,
|
||||
_bfd_dummy_target, aix386_core_file_p},
|
||||
{bfd_false, bfd_false, /* bfd_create_object */
|
||||
bfd_false, bfd_false},
|
||||
{bfd_false, bfd_false, /* bfd_write_contents */
|
||||
bfd_false, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (aix386),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
(PTR) 0
|
||||
};
|
||||
@@ -1,367 +0,0 @@
|
||||
/* IBM RS/6000 "XCOFF" back-end for BFD.
|
||||
Copyright 2001, 2002, 2004
|
||||
Free Software Foundation, Inc.
|
||||
Written by Tom Rix
|
||||
Contributed by Redhat.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
#ifdef AIX_5_CORE
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_target *xcoff64_core_p
|
||||
PARAMS ((bfd *));
|
||||
bfd_boolean xcoff64_core_file_matches_executable_p
|
||||
PARAMS ((bfd *, bfd *));
|
||||
char *xcoff64_core_file_failing_command
|
||||
PARAMS ((bfd *));
|
||||
int xcoff64_core_file_failing_signal
|
||||
PARAMS ((bfd *));
|
||||
|
||||
/* 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>
|
||||
|
||||
#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 (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
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;
|
||||
bfd_target *return_value = NULL;
|
||||
|
||||
/* 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 = (struct core_dumpxx *)
|
||||
bfd_zalloc (abfd, sizeof (struct core_dumpxx));
|
||||
if (NULL == new_core_hdr)
|
||||
return return_value;
|
||||
|
||||
memcpy (new_core_hdr, &core, sizeof (struct core_dumpxx));
|
||||
core_hdr(abfd) = (char *)new_core_hdr;
|
||||
|
||||
/* .stack section. */
|
||||
sec = bfd_make_section_anyway (abfd, ".stack");
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
sec->size = core.c_size;
|
||||
sec->vma = core.c_stackorg;
|
||||
sec->filepos = core.c_stack;
|
||||
|
||||
/* .reg section for all registers. */
|
||||
sec = bfd_make_section_anyway (abfd, ".reg");
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
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. */
|
||||
sec = bfd_make_section_anyway (abfd, ".ldinfo");
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->flags = SEC_HAS_CONTENTS;
|
||||
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. */
|
||||
sec = bfd_make_section_anyway (abfd, ".data");
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
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)
|
||||
{
|
||||
sec = bfd_make_section_anyway (abfd, ".data");
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
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)
|
||||
{
|
||||
sec = bfd_make_section_anyway (abfd, ".vmdata");
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
sec->size = vminfo.vminfo_size;
|
||||
sec->vma = vminfo.vminfo_addr;
|
||||
sec->filepos = vminfo.vminfo_offset;
|
||||
}
|
||||
}
|
||||
|
||||
return_value = 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 (core_bfd, exec_bfd)
|
||||
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 (abfd)
|
||||
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 (abfd)
|
||||
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
|
||||
PARAMS ((bfd *));
|
||||
bfd_boolean xcoff64_core_file_matches_executable_p
|
||||
PARAMS ((bfd *, bfd *));
|
||||
char *xcoff64_core_file_failing_command
|
||||
PARAMS ((bfd *));
|
||||
int xcoff64_core_file_failing_signal
|
||||
PARAMS ((bfd *));
|
||||
|
||||
const bfd_target *
|
||||
xcoff64_core_p (abfd)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bfd_boolean
|
||||
xcoff64_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd ATTRIBUTE_UNUSED;
|
||||
bfd *exec_bfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char *
|
||||
xcoff64_core_file_failing_command (abfd)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
xcoff64_core_file_failing_signal (abfd)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* AIX_5_CORE */
|
||||
573
bfd/aout-adobe.c
573
bfd/aout-adobe.c
@@ -1,573 +0,0 @@
|
||||
/* BFD back-end for a.out.adobe binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
|
||||
2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support. Based on bout.c.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "aout/adobe.h"
|
||||
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures. */
|
||||
|
||||
/* Forward decl. */
|
||||
extern const bfd_target a_out_adobe_vec;
|
||||
|
||||
static const bfd_target *aout_adobe_callback
|
||||
PARAMS ((bfd *));
|
||||
extern bfd_boolean aout_32_slurp_symbol_table
|
||||
PARAMS ((bfd *abfd));
|
||||
extern bfd_boolean aout_32_write_syms
|
||||
PARAMS ((bfd *));
|
||||
static void aout_adobe_write_section
|
||||
PARAMS ((bfd *abfd, sec_ptr sect));
|
||||
static const bfd_target * aout_adobe_object_p
|
||||
PARAMS ((bfd *));
|
||||
static bfd_boolean aout_adobe_mkobject
|
||||
PARAMS ((bfd *));
|
||||
static bfd_boolean aout_adobe_write_object_contents
|
||||
PARAMS ((bfd *));
|
||||
static bfd_boolean aout_adobe_set_section_contents
|
||||
PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
|
||||
static bfd_boolean aout_adobe_set_arch_mach
|
||||
PARAMS ((bfd *, enum bfd_architecture, unsigned long));
|
||||
static int aout_adobe_sizeof_headers
|
||||
PARAMS ((bfd *, bfd_boolean));
|
||||
|
||||
/* Swaps the information in an executable header taken from a raw byte
|
||||
stream memory image, into the internal exec_header structure. */
|
||||
|
||||
void aout_adobe_swap_exec_header_in
|
||||
PARAMS ((bfd *, struct external_exec *, struct internal_exec *));
|
||||
|
||||
void
|
||||
aout_adobe_swap_exec_header_in (abfd, raw_bytes, execp)
|
||||
bfd *abfd;
|
||||
struct external_exec *raw_bytes;
|
||||
struct internal_exec *execp;
|
||||
{
|
||||
struct external_exec *bytes = (struct external_exec *) raw_bytes;
|
||||
|
||||
/* Now fill in fields in the execp, from the bytes in the raw data. */
|
||||
execp->a_info = H_GET_32 (abfd, bytes->e_info);
|
||||
execp->a_text = GET_WORD (abfd, bytes->e_text);
|
||||
execp->a_data = GET_WORD (abfd, bytes->e_data);
|
||||
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
|
||||
execp->a_syms = GET_WORD (abfd, bytes->e_syms);
|
||||
execp->a_entry = GET_WORD (abfd, bytes->e_entry);
|
||||
execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
|
||||
execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
|
||||
}
|
||||
|
||||
/* Swaps the information in an internal exec header structure into the
|
||||
supplied buffer ready for writing to disk. */
|
||||
|
||||
void aout_adobe_swap_exec_header_out
|
||||
PARAMS ((bfd *, struct internal_exec *, struct external_exec *));
|
||||
|
||||
void
|
||||
aout_adobe_swap_exec_header_out (abfd, execp, raw_bytes)
|
||||
bfd *abfd;
|
||||
struct internal_exec *execp;
|
||||
struct external_exec *raw_bytes;
|
||||
{
|
||||
struct external_exec *bytes = (struct external_exec *) raw_bytes;
|
||||
|
||||
/* Now fill in fields in the raw data, from the fields in the exec
|
||||
struct. */
|
||||
H_PUT_32 (abfd, execp->a_info , bytes->e_info);
|
||||
PUT_WORD (abfd, execp->a_text , bytes->e_text);
|
||||
PUT_WORD (abfd, execp->a_data , bytes->e_data);
|
||||
PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
|
||||
PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
|
||||
PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
|
||||
PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
|
||||
PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
|
||||
}
|
||||
|
||||
static const bfd_target *
|
||||
aout_adobe_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec anexec;
|
||||
struct external_exec exec_bytes;
|
||||
char *targ;
|
||||
bfd_size_type amt = EXEC_BYTES_SIZE;
|
||||
|
||||
if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
anexec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
|
||||
|
||||
/* Normally we just compare for the magic number.
|
||||
However, a bunch of Adobe tools aren't fixed up yet; they generate
|
||||
files using ZMAGIC(!).
|
||||
If the environment variable GNUTARGET is set to "a.out.adobe", we will
|
||||
take just about any a.out file as an Adobe a.out file. FIXME! */
|
||||
|
||||
if (N_BADMAG (anexec))
|
||||
{
|
||||
targ = getenv ("GNUTARGET");
|
||||
if (targ && !strcmp (targ, a_out_adobe_vec.name))
|
||||
/* Just continue anyway, if specifically set to this format. */
|
||||
;
|
||||
else
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
aout_adobe_swap_exec_header_in (abfd, &exec_bytes, &anexec);
|
||||
return aout_32_some_aout_object_p (abfd, &anexec, aout_adobe_callback);
|
||||
}
|
||||
|
||||
/* Finish up the opening of a b.out file for reading. Fill in all the
|
||||
fields that are not handled by common code. */
|
||||
|
||||
static const bfd_target *
|
||||
aout_adobe_callback (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
asection *sect;
|
||||
struct external_segdesc ext[1];
|
||||
char *section_name;
|
||||
char try_again[30]; /* Name and number. */
|
||||
char *newname;
|
||||
int trynum;
|
||||
flagword flags;
|
||||
|
||||
/* Architecture and machine type -- unknown in this format. */
|
||||
bfd_set_arch_mach (abfd, bfd_arch_unknown, 0L);
|
||||
|
||||
/* The positions of the string table and symbol table. */
|
||||
obj_str_filepos (abfd) = N_STROFF (*execp);
|
||||
obj_sym_filepos (abfd) = N_SYMOFF (*execp);
|
||||
|
||||
/* Suck up the section information from the file, one section at a time. */
|
||||
for (;;)
|
||||
{
|
||||
bfd_size_type amt = sizeof (*ext);
|
||||
if (bfd_bread ((PTR) ext, amt, abfd) != amt)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
return 0;
|
||||
}
|
||||
switch (ext->e_type[0])
|
||||
{
|
||||
case N_TEXT:
|
||||
section_name = ".text";
|
||||
flags = SEC_CODE | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case N_DATA:
|
||||
section_name = ".data";
|
||||
flags = SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case N_BSS:
|
||||
section_name = ".bss";
|
||||
flags = SEC_DATA | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
goto no_more_sections;
|
||||
|
||||
default:
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: Unknown section type in a.out.adobe file: %x\n"),
|
||||
abfd, ext->e_type[0]);
|
||||
goto no_more_sections;
|
||||
}
|
||||
|
||||
/* First one is called ".text" or whatever; subsequent ones are
|
||||
".text1", ".text2", ... */
|
||||
bfd_set_error (bfd_error_no_error);
|
||||
sect = bfd_make_section (abfd, section_name);
|
||||
trynum = 0;
|
||||
|
||||
while (!sect)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_no_error)
|
||||
/* Some other error -- slide into the sunset. */
|
||||
return 0;
|
||||
sprintf (try_again, "%s%d", section_name, ++trynum);
|
||||
sect = bfd_make_section (abfd, try_again);
|
||||
}
|
||||
|
||||
/* Fix the name, if it is a sprintf'd name. */
|
||||
if (sect->name == try_again)
|
||||
{
|
||||
amt = strlen (sect->name);
|
||||
newname = (char *) bfd_zalloc (abfd, amt);
|
||||
if (newname == NULL)
|
||||
return 0;
|
||||
strcpy (newname, sect->name);
|
||||
sect->name = newname;
|
||||
}
|
||||
|
||||
/* Now set the section's attributes. */
|
||||
bfd_set_section_flags (abfd, sect, flags);
|
||||
/* Assumed big-endian. */
|
||||
sect->size = ((ext->e_size[0] << 8)
|
||||
| ext->e_size[1] << 8
|
||||
| ext->e_size[2]);
|
||||
sect->vma = H_GET_32 (abfd, ext->e_virtbase);
|
||||
sect->filepos = H_GET_32 (abfd, ext->e_filebase);
|
||||
/* FIXME XXX alignment? */
|
||||
|
||||
/* Set relocation information for first section of each type. */
|
||||
if (trynum == 0)
|
||||
switch (ext->e_type[0])
|
||||
{
|
||||
case N_TEXT:
|
||||
sect->rel_filepos = N_TRELOFF (*execp);
|
||||
sect->reloc_count = execp->a_trsize;
|
||||
break;
|
||||
|
||||
case N_DATA:
|
||||
sect->rel_filepos = N_DRELOFF (*execp);
|
||||
sect->reloc_count = execp->a_drsize;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
no_more_sections:
|
||||
|
||||
adata (abfd).reloc_entry_size = sizeof (struct reloc_std_external);
|
||||
adata (abfd).symbol_entry_size = sizeof (struct external_nlist);
|
||||
adata (abfd).page_size = 1; /* Not applicable. */
|
||||
adata (abfd).segment_size = 1; /* Not applicable. */
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
struct bout_data_struct
|
||||
{
|
||||
struct aoutdata a;
|
||||
struct internal_exec e;
|
||||
};
|
||||
|
||||
static bfd_boolean
|
||||
aout_adobe_mkobject (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct bout_data_struct *rawptr;
|
||||
bfd_size_type amt = sizeof (struct bout_data_struct);
|
||||
|
||||
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, amt);
|
||||
if (rawptr == NULL)
|
||||
return FALSE;
|
||||
|
||||
abfd->tdata.bout_data = rawptr;
|
||||
exec_hdr (abfd) = &rawptr->e;
|
||||
|
||||
adata (abfd).reloc_entry_size = sizeof (struct reloc_std_external);
|
||||
adata (abfd).symbol_entry_size = sizeof (struct external_nlist);
|
||||
adata (abfd).page_size = 1; /* Not applicable. */
|
||||
adata (abfd).segment_size = 1; /* Not applicable. */
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
aout_adobe_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec swapped_hdr;
|
||||
static struct external_segdesc sentinel[1]; /* Initialized to zero. */
|
||||
asection *sect;
|
||||
bfd_size_type amt;
|
||||
|
||||
exec_hdr (abfd)->a_info = ZMAGIC;
|
||||
|
||||
/* Calculate text size as total of text sections, etc. */
|
||||
|
||||
exec_hdr (abfd)->a_text = 0;
|
||||
exec_hdr (abfd)->a_data = 0;
|
||||
exec_hdr (abfd)->a_bss = 0;
|
||||
exec_hdr (abfd)->a_trsize = 0;
|
||||
exec_hdr (abfd)->a_drsize = 0;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
{
|
||||
if (sect->flags & SEC_CODE)
|
||||
{
|
||||
exec_hdr (abfd)->a_text += sect->size;
|
||||
exec_hdr (abfd)->a_trsize += sect->reloc_count *
|
||||
sizeof (struct reloc_std_external);
|
||||
}
|
||||
else if (sect->flags & SEC_DATA)
|
||||
{
|
||||
exec_hdr (abfd)->a_data += sect->size;
|
||||
exec_hdr (abfd)->a_drsize += sect->reloc_count *
|
||||
sizeof (struct reloc_std_external);
|
||||
}
|
||||
else if (sect->flags & SEC_ALLOC && !(sect->flags & SEC_LOAD))
|
||||
{
|
||||
exec_hdr (abfd)->a_bss += sect->size;
|
||||
}
|
||||
}
|
||||
|
||||
exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd)
|
||||
* sizeof (struct external_nlist);
|
||||
exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
|
||||
|
||||
aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
|
||||
|
||||
amt = EXEC_BYTES_SIZE;
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||
|| bfd_bwrite ((PTR) &swapped_hdr, amt, abfd) != amt)
|
||||
return FALSE;
|
||||
|
||||
/* Now write out the section information. Text first, data next, rest
|
||||
afterward. */
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
if (sect->flags & SEC_CODE)
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
if (sect->flags & SEC_DATA)
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
if (!(sect->flags & (SEC_CODE | SEC_DATA)))
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
|
||||
/* Write final `sentinel` section header (with type of 0). */
|
||||
amt = sizeof (*sentinel);
|
||||
if (bfd_bwrite ((PTR) sentinel, amt, abfd) != amt)
|
||||
return FALSE;
|
||||
|
||||
/* Now write out reloc info, followed by syms and strings. */
|
||||
if (bfd_get_symcount (abfd) != 0)
|
||||
{
|
||||
if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*exec_hdr (abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return FALSE;
|
||||
|
||||
if (! aout_32_write_syms (abfd))
|
||||
return FALSE;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*exec_hdr (abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return FALSE;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
if (sect->flags & SEC_CODE)
|
||||
if (!aout_32_squirt_out_relocs (abfd, sect))
|
||||
return FALSE;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*exec_hdr (abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return FALSE;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
if (sect->flags & SEC_DATA)
|
||||
if (!aout_32_squirt_out_relocs (abfd, sect))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
aout_adobe_write_section (abfd, sect)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
sec_ptr sect ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME XXX */
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
aout_adobe_set_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
const PTR location;
|
||||
file_ptr offset;
|
||||
bfd_size_type count;
|
||||
{
|
||||
file_ptr section_start;
|
||||
sec_ptr sect;
|
||||
|
||||
/* Set by bfd.c handler. */
|
||||
if (! abfd->output_has_begun)
|
||||
{
|
||||
/* Assign file offsets to sections. Text sections are first, and
|
||||
are contiguous. Then data sections. Everything else at the end. */
|
||||
section_start = N_TXTOFF (ignore<-->me);
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
{
|
||||
if (sect->flags & SEC_CODE)
|
||||
{
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment. */
|
||||
section_start += sect->size;
|
||||
}
|
||||
}
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
{
|
||||
if (sect->flags & SEC_DATA)
|
||||
{
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment. */
|
||||
section_start += sect->size;
|
||||
}
|
||||
}
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next)
|
||||
{
|
||||
if (sect->flags & SEC_HAS_CONTENTS &&
|
||||
!(sect->flags & (SEC_CODE | SEC_DATA)))
|
||||
{
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment. */
|
||||
section_start += sect->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Regardless, once we know what we're doing, we might as well get
|
||||
going. */
|
||||
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
|
||||
return FALSE;
|
||||
|
||||
if (count == 0)
|
||||
return TRUE;
|
||||
|
||||
return bfd_bwrite ((PTR) location, count, abfd) == count;
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
aout_adobe_set_arch_mach (abfd, arch, machine)
|
||||
bfd *abfd;
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
if (! bfd_default_set_arch_mach (abfd, arch, machine))
|
||||
return FALSE;
|
||||
|
||||
if (arch == bfd_arch_unknown
|
||||
|| arch == bfd_arch_m68k)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
aout_adobe_sizeof_headers (ignore_abfd, ignore)
|
||||
bfd *ignore_abfd ATTRIBUTE_UNUSED;
|
||||
bfd_boolean ignore ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return sizeof (struct internal_exec);
|
||||
}
|
||||
|
||||
/* Build the transfer vector for Adobe A.Out files. */
|
||||
|
||||
#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
|
||||
|
||||
#define aout_32_bfd_make_debug_symbol \
|
||||
((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
|
||||
|
||||
#define aout_32_bfd_reloc_type_lookup \
|
||||
((reloc_howto_type *(*) \
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
|
||||
|
||||
#define aout_32_set_arch_mach aout_adobe_set_arch_mach
|
||||
#define aout_32_set_section_contents aout_adobe_set_section_contents
|
||||
|
||||
#define aout_32_sizeof_headers aout_adobe_sizeof_headers
|
||||
#define aout_32_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
|
||||
#define aout_32_bfd_relax_section bfd_generic_relax_section
|
||||
#define aout_32_bfd_gc_sections bfd_generic_gc_sections
|
||||
#define aout_32_bfd_merge_sections bfd_generic_merge_sections
|
||||
#define aout_32_bfd_is_group_section bfd_generic_is_group_section
|
||||
#define aout_32_bfd_discard_group bfd_generic_discard_group
|
||||
#define aout_32_section_already_linked \
|
||||
_bfd_generic_section_already_linked
|
||||
#define aout_32_bfd_link_hash_table_create \
|
||||
_bfd_generic_link_hash_table_create
|
||||
#define aout_32_bfd_link_hash_table_free \
|
||||
_bfd_generic_link_hash_table_free
|
||||
#define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define aout_32_bfd_link_just_syms _bfd_generic_link_just_syms
|
||||
#define aout_32_bfd_final_link _bfd_generic_final_link
|
||||
#define aout_32_bfd_link_split_section _bfd_generic_link_split_section
|
||||
|
||||
const bfd_target a_out_adobe_vec =
|
||||
{
|
||||
"a.out.adobe", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is unknown (big assumed) */
|
||||
BFD_ENDIAN_BIG, /* hdr byte order is big */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
/* section flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_DATA | SEC_RELOC),
|
||||
'_', /* symbol leading char */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
{_bfd_dummy_target, aout_adobe_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, aout_adobe_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, aout_adobe_write_object_contents,/* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (aout_32),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
|
||||
BFD_JUMP_TABLE_SYMBOLS (aout_32),
|
||||
BFD_JUMP_TABLE_RELOCS (aout_32),
|
||||
BFD_JUMP_TABLE_WRITE (aout_32),
|
||||
BFD_JUMP_TABLE_LINK (aout_32),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
(PTR) 0
|
||||
};
|
||||
565
bfd/aout-arm.c
565
bfd/aout-arm.c
@@ -1,565 +0,0 @@
|
||||
/* BFD back-end for raw ARM a.out binaries.
|
||||
Copyright 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
/* Avoid multiple definitions from aoutx if supporting standard a.out
|
||||
as well as our own. */
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define NAME(x,y) CONCAT3 (aoutarm,_32_,y)
|
||||
|
||||
#define N_TXTADDR(x) \
|
||||
((N_MAGIC (x) == NMAGIC) \
|
||||
? (bfd_vma) 0x8000 \
|
||||
: ((N_MAGIC (x) != ZMAGIC) \
|
||||
? (bfd_vma) 0 \
|
||||
: ((N_SHARED_LIB (x)) \
|
||||
? ((x).a_entry & ~(bfd_vma) (TARGET_PAGE_SIZE - 1)) \
|
||||
: (bfd_vma) TEXT_START_ADDR)))
|
||||
|
||||
#define TEXT_START_ADDR 0x8000
|
||||
#define TARGET_PAGE_SIZE 0x8000
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define DEFAULT_ARCH bfd_arch_arm
|
||||
|
||||
#define MY(OP) CONCAT2 (aoutarm_,OP)
|
||||
#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
|
||||
(((x).a_info & ~006000) != OMAGIC) && \
|
||||
((x).a_info != NMAGIC))
|
||||
#define N_MAGIC(x) ((x).a_info & ~07200)
|
||||
|
||||
#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
|
||||
|
||||
#include "libaout.h"
|
||||
#include "aout/aout64.h"
|
||||
|
||||
static bfd_boolean MY(write_object_contents)
|
||||
PARAMS ((bfd *));
|
||||
static bfd_reloc_status_type MY(fix_pcrel_26_done)
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type MY(fix_pcrel_26)
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static void MY(swap_std_reloc_in)
|
||||
PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **,
|
||||
bfd_size_type));
|
||||
reloc_howto_type *MY(bfd_reloc_type_lookup)
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
reloc_howto_type * MY(reloc_howto)
|
||||
PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *));
|
||||
void MY(put_reloc)
|
||||
PARAMS ((bfd *, int, int, bfd_vma, reloc_howto_type *,
|
||||
struct reloc_std_external *));
|
||||
void MY(relocatable_reloc)
|
||||
PARAMS ((reloc_howto_type *, bfd *, struct reloc_std_external *, bfd_vma *,
|
||||
bfd_vma));
|
||||
void MY(swap_std_reloc_out)
|
||||
PARAMS ((bfd *, arelent *, struct reloc_std_external *));
|
||||
|
||||
reloc_howto_type MY(howto_table)[] =
|
||||
{
|
||||
/* Type rs size bsz pcrel bitpos ovrf sf name part_inpl
|
||||
readmask setmask pcdone. */
|
||||
HOWTO (0, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "8", TRUE,
|
||||
0x000000ff, 0x000000ff, FALSE),
|
||||
HOWTO (1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "16", TRUE,
|
||||
0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO (2, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "32", TRUE,
|
||||
0xffffffff, 0xffffffff, FALSE),
|
||||
HOWTO (3, 2, 2, 26, TRUE, 0, complain_overflow_signed, MY(fix_pcrel_26),
|
||||
"ARM26", TRUE, 0x00ffffff, 0x00ffffff, TRUE),
|
||||
HOWTO (4, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, "DISP8", TRUE,
|
||||
0x000000ff, 0x000000ff, TRUE),
|
||||
HOWTO (5, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "DISP16", TRUE,
|
||||
0x0000ffff, 0x0000ffff, TRUE),
|
||||
HOWTO (6, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "DISP32", TRUE,
|
||||
0xffffffff, 0xffffffff, TRUE),
|
||||
HOWTO (7, 2, 2, 26, FALSE, 0, complain_overflow_signed,
|
||||
MY(fix_pcrel_26_done), "ARM26D", TRUE, 0x0, 0x0,
|
||||
FALSE),
|
||||
EMPTY_HOWTO (-1),
|
||||
HOWTO (9, 0, -1, 16, FALSE, 0, complain_overflow_bitfield, 0, "NEG16", TRUE,
|
||||
0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO (10, 0, -2, 32, FALSE, 0, complain_overflow_bitfield, 0, "NEG32", TRUE,
|
||||
0xffffffff, 0xffffffff, FALSE)
|
||||
};
|
||||
|
||||
#define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08)
|
||||
#define RELOC_ARM_BITS_NEG_LITTLE ((unsigned int) 0x10)
|
||||
|
||||
reloc_howto_type *
|
||||
MY(reloc_howto) (abfd, rel, r_index, r_extern, r_pcrel)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *rel;
|
||||
int *r_index;
|
||||
int *r_extern;
|
||||
int *r_pcrel;
|
||||
{
|
||||
unsigned int r_length;
|
||||
unsigned int r_pcrel_done;
|
||||
unsigned int r_neg;
|
||||
int index;
|
||||
|
||||
*r_pcrel = 0;
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
*r_index = ((rel->r_index[0] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[2]);
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
|
||||
r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
|
||||
r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_BIG));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_BIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
*r_index = ((rel->r_index[2] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[0]);
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
|
||||
r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
|
||||
r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_LITTLE));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||
}
|
||||
index = r_length + 4 * r_pcrel_done + 8 * r_neg;
|
||||
if (index == 3)
|
||||
*r_pcrel = 1;
|
||||
|
||||
return MY(howto_table) + index;
|
||||
}
|
||||
|
||||
#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
|
||||
MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
|
||||
|
||||
void
|
||||
MY(put_reloc) (abfd, r_extern, r_index, value, howto, reloc)
|
||||
bfd *abfd;
|
||||
int r_extern;
|
||||
int r_index;
|
||||
bfd_vma value;
|
||||
reloc_howto_type *howto;
|
||||
struct reloc_std_external *reloc;
|
||||
{
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
int r_neg;
|
||||
|
||||
PUT_WORD (abfd, value, reloc->r_address);
|
||||
/* Size as a power of two. */
|
||||
r_length = howto->size;
|
||||
|
||||
/* Special case for branch relocations. */
|
||||
if (howto->type == 3 || howto->type == 7)
|
||||
r_length = 3;
|
||||
|
||||
r_pcrel = howto->type & 4; /* PC Relative done? */
|
||||
r_neg = howto->type & 8; /* Negative relocation. */
|
||||
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
reloc->r_index[0] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[2] = r_index;
|
||||
reloc->r_type[0] =
|
||||
((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_BIG : 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
|
||||
}
|
||||
else
|
||||
{
|
||||
reloc->r_index[2] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[0] = r_index;
|
||||
reloc->r_type[0] =
|
||||
((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_LITTLE : 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
|
||||
MY(put_reloc) (BFD, EXT, IDX, VAL, HOWTO, RELOC)
|
||||
|
||||
void
|
||||
MY(relocatable_reloc) (howto, abfd, reloc, amount, r_addr)
|
||||
reloc_howto_type *howto;
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *reloc;
|
||||
bfd_vma *amount;
|
||||
bfd_vma r_addr;
|
||||
{
|
||||
if (howto->type == 3)
|
||||
{
|
||||
if (reloc->r_type[0]
|
||||
& (bfd_header_big_endian (abfd)
|
||||
? RELOC_STD_BITS_EXTERN_BIG : RELOC_STD_BITS_EXTERN_LITTLE))
|
||||
{
|
||||
/* The reloc is still external, so don't modify anything. */
|
||||
*amount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*amount -= r_addr;
|
||||
/* Change the r_pcrel value -- on the ARM, this bit is set once the
|
||||
relocation is done. */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
reloc->r_type[0] |= RELOC_STD_BITS_PCREL_BIG;
|
||||
else
|
||||
reloc->r_type[0] |= RELOC_STD_BITS_PCREL_LITTLE;
|
||||
}
|
||||
}
|
||||
else if (howto->type == 7)
|
||||
*amount = 0;
|
||||
}
|
||||
|
||||
#define MY_relocatable_reloc(HOW, BFD, REL, AMOUNT, ADDR) \
|
||||
MY(relocatable_reloc) (HOW, BFD, REL, &(AMOUNT), ADDR)
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26_done) (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* This is dead simple at present. */
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
bfd_size_type addr = reloc_entry->address;
|
||||
bfd_vma target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
|
||||
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||
|
||||
/* If this is an undefined symbol, return error. */
|
||||
if (symbol->section == &bfd_und_section
|
||||
&& (symbol->flags & BSF_WEAK) == 0)
|
||||
return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
|
||||
|
||||
/* If the sections are different, and we are doing a partial relocation,
|
||||
just ignore it for now. */
|
||||
if (symbol->section->name != input_section->name
|
||||
&& output_bfd != (bfd *)NULL)
|
||||
return bfd_reloc_ok;
|
||||
|
||||
relocation = (target & 0x00ffffff) << 2;
|
||||
relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend. */
|
||||
relocation += symbol->value;
|
||||
relocation += symbol->section->output_section->vma;
|
||||
relocation += symbol->section->output_offset;
|
||||
relocation += reloc_entry->addend;
|
||||
relocation -= input_section->output_section->vma;
|
||||
relocation -= input_section->output_offset;
|
||||
relocation -= addr;
|
||||
if (relocation & 3)
|
||||
return bfd_reloc_overflow;
|
||||
|
||||
/* Check for overflow. */
|
||||
if (relocation & 0x02000000)
|
||||
{
|
||||
if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
else if (relocation & ~ (bfd_vma) 0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
|
||||
target &= ~ (bfd_vma) 0x00ffffff;
|
||||
target |= (relocation >> 2) & 0x00ffffff;
|
||||
bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
|
||||
|
||||
/* Now the ARM magic... Change the reloc type so that it is marked as done.
|
||||
Strictly this is only necessary if we are doing a partial relocation. */
|
||||
reloc_entry->howto = &MY(howto_table)[7];
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
reloc_howto_type *
|
||||
MY(bfd_reloc_type_lookup) (abfd,code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
#define ASTD(i,j) case i: return &MY(howto_table)[j]
|
||||
if (code == BFD_RELOC_CTOR)
|
||||
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||
{
|
||||
case 32:
|
||||
code = BFD_RELOC_32;
|
||||
break;
|
||||
default:
|
||||
return (const struct reloc_howto_struct *) 0;
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
ASTD (BFD_RELOC_16, 1);
|
||||
ASTD (BFD_RELOC_32, 2);
|
||||
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
|
||||
ASTD (BFD_RELOC_8_PCREL, 4);
|
||||
ASTD (BFD_RELOC_16_PCREL, 5);
|
||||
ASTD (BFD_RELOC_32_PCREL, 6);
|
||||
default:
|
||||
return (const struct reloc_howto_struct *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
|
||||
#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
|
||||
#define MY_get_section_contents _bfd_generic_get_section_contents
|
||||
/* #define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create */
|
||||
/* #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols */
|
||||
/* #define MY_bfd_final_link _bfd_generic_final_link */
|
||||
|
||||
#include "aoutx.h"
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount ATTRIBUTE_UNUSED;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
int r_pcrel;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
|
||||
|
||||
cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel);
|
||||
|
||||
MOVE_ADDRESS (0);
|
||||
}
|
||||
|
||||
void
|
||||
MY_swap_std_reloc_out (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
struct reloc_std_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
int r_extern;
|
||||
int r_length;
|
||||
int r_pcrel;
|
||||
int r_neg = 0; /* Negative relocs use the BASEREL bit. */
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
PUT_WORD(abfd, g->address, natptr->r_address);
|
||||
|
||||
r_length = g->howto->size ; /* Size as a power of two */
|
||||
if (r_length < 0)
|
||||
{
|
||||
r_length = -r_length;
|
||||
r_neg = 1;
|
||||
}
|
||||
|
||||
r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
|
||||
|
||||
/* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
|
||||
relocation has been done already (Only for the 26-bit one I think)???!!!
|
||||
*/
|
||||
|
||||
if (g->howto->type == 3)
|
||||
{
|
||||
r_length = 3;
|
||||
r_pcrel = 0;
|
||||
}
|
||||
else if (g->howto->type == 7)
|
||||
{
|
||||
r_length = 3;
|
||||
r_pcrel = 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* For a standard reloc, the addend is in the object file. */
|
||||
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
#endif
|
||||
|
||||
/* name was clobbered by aout_write_syms to be symbol index */
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
check for that here
|
||||
*/
|
||||
|
||||
if (bfd_is_com_section (output_section)
|
||||
|| output_section == &bfd_abs_section
|
||||
|| output_section == &bfd_und_section)
|
||||
{
|
||||
if (bfd_abs_section.symbol == sym)
|
||||
{
|
||||
/* Whoops, looked like an abs symbol, but is really an offset
|
||||
from the abs section. */
|
||||
r_index = 0;
|
||||
r_extern = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fill in symbol. */
|
||||
r_extern = 1;
|
||||
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section. */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
/* Now the fun stuff. */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
natptr->r_index[0] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[2] = r_index;
|
||||
natptr->r_type[0] =
|
||||
( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_BIG: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
|
||||
}
|
||||
else
|
||||
{
|
||||
natptr->r_index[2] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[0] = r_index;
|
||||
natptr->r_type[0] =
|
||||
( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_LITTLE: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_BFD_TARGET
|
||||
|
||||
#include "aout-target.h"
|
||||
|
||||
extern const bfd_target aout_arm_big_vec;
|
||||
|
||||
const bfd_target aout_arm_little_vec =
|
||||
{
|
||||
"a.out-arm-little", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* target byte order (little) */
|
||||
BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
|
||||
MY_symbol_leading_char,
|
||||
AR_PAD_CHAR, /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, MY_core_file_p},
|
||||
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (MY),
|
||||
BFD_JUMP_TABLE_COPY (MY),
|
||||
BFD_JUMP_TABLE_CORE (MY),
|
||||
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||
BFD_JUMP_TABLE_RELOCS (MY),
|
||||
BFD_JUMP_TABLE_WRITE (MY),
|
||||
BFD_JUMP_TABLE_LINK (MY),
|
||||
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||
|
||||
& aout_arm_big_vec,
|
||||
|
||||
(PTR) MY_backend_data,
|
||||
};
|
||||
|
||||
const bfd_target aout_arm_big_vec =
|
||||
{
|
||||
"a.out-arm-big", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order (big) */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order (big) */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
|
||||
MY_symbol_leading_char,
|
||||
AR_PAD_CHAR, /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, MY_core_file_p},
|
||||
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (MY),
|
||||
BFD_JUMP_TABLE_COPY (MY),
|
||||
BFD_JUMP_TABLE_CORE (MY),
|
||||
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||
BFD_JUMP_TABLE_RELOCS (MY),
|
||||
BFD_JUMP_TABLE_WRITE (MY),
|
||||
BFD_JUMP_TABLE_LINK (MY),
|
||||
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||
|
||||
& aout_arm_little_vec,
|
||||
|
||||
(PTR) MY_backend_data,
|
||||
};
|
||||
306
bfd/aout-cris.c
306
bfd/aout-cris.c
@@ -1,306 +0,0 @@
|
||||
/* BFD backend for CRIS a.out binaries.
|
||||
Copyright 2000, 2001, 2002, 2003, 2004 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* See info in the file PORTING for documentation of these macros and
|
||||
functions. Beware; some of the information there is outdated. */
|
||||
|
||||
#define N_HEADER_IN_TEXT(x) 0
|
||||
#define N_TXTOFF(x) 32
|
||||
#define ENTRY_CAN_BE_ZERO
|
||||
#define TEXT_START_ADDR 0
|
||||
|
||||
/* Without reading symbols to get the text start symbol, there is no way
|
||||
to know where the text segment starts in an a.out file. Defaulting to
|
||||
anything as constant as TEXT_START_ADDR is bad. But we can guess from
|
||||
the entry point, which is usually within the first 64k of the text
|
||||
segment. We also assume here that the text segment is 64k-aligned.
|
||||
FIXME: It is also wrong to assume that data and bss follow immediately
|
||||
after text, but with those, we don't have any choice besides reading
|
||||
symbol info, and luckily there's no pressing need for correctness for
|
||||
those vma:s at this time. */
|
||||
#define N_TXTADDR(x) ((x).a_entry & ~(bfd_vma) 0xffff)
|
||||
|
||||
/* If you change this to 4, you can not link to an address N*4+2. */
|
||||
#define SEGMENT_SIZE 2
|
||||
|
||||
/* For some reason, if the a.out file has Z_MAGIC, then
|
||||
adata(abfd).exec_bytes_size is not used, but rather
|
||||
adata(abfd).zmagic_disk_block_size, even though the exec_header is
|
||||
*not* included in the text segment. A simple workaround is to
|
||||
#define ZMAGIC_DISK_BLOCK_SIZE, which is used if defined; otherwise
|
||||
TARGET_PAGE_SIZE is used. */
|
||||
#define ZMAGIC_DISK_BLOCK_SIZE N_TXTOFF (0)
|
||||
|
||||
/* It seems odd at first to set a page-size this low, but gives greater
|
||||
freedom in where things can be linked. The drawback is that you have
|
||||
to set alignment and padding in linker scripts. */
|
||||
#define TARGET_PAGE_SIZE SEGMENT_SIZE
|
||||
#define TARGETNAME "a.out-cris"
|
||||
|
||||
/* N_SHARED_LIB gets this reasonable default as of 1999-07-12, but we
|
||||
have to work with 2.9.1. Note that N_SHARED_LIB is used in a
|
||||
SUN-specific context, not applicable to CRIS. */
|
||||
#define N_SHARED_LIB(x) 0
|
||||
|
||||
/* The definition here seems not used; just provided as a convention. */
|
||||
#define DEFAULT_ARCH bfd_arch_cris
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MY(OP) CONCAT2 (cris_aout_,OP)
|
||||
#define NAME(x, y) CONCAT3 (cris_aout,_32_,y)
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
/* Version 1 of the header. */
|
||||
#define MY_exec_hdr_flags 1
|
||||
|
||||
#define MY_write_object_contents MY(write_object_contents)
|
||||
static bfd_boolean MY(write_object_contents) PARAMS ((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) PARAMS ((bfd *, arelent *,
|
||||
struct reloc_ext_external *));
|
||||
|
||||
#define MY_swap_ext_reloc_in MY(swap_ext_reloc_in)
|
||||
static void MY(swap_ext_reloc_in) PARAMS ((bfd *, struct
|
||||
reloc_ext_external *,
|
||||
arelent *, asymbol **,
|
||||
bfd_size_type));
|
||||
|
||||
#define MY_set_sizes MY(set_sizes)
|
||||
static bfd_boolean MY(set_sizes) PARAMS ((bfd *));
|
||||
|
||||
/* To set back reloc_size to ext, we make MY(set_sizes) be called
|
||||
through this construct. Note that MY_set_arch_mach is only called
|
||||
through SET_ARCH_MACH. The default bfd_default_set_arch_mach will
|
||||
not call set_sizes. */
|
||||
|
||||
#define MY_set_arch_mach NAME (aout, set_arch_mach)
|
||||
#define SET_ARCH_MACH(BFD, EXEC) \
|
||||
MY_set_arch_mach (BFD, DEFAULT_ARCH, N_MACHTYPE (EXEC))
|
||||
|
||||
/* These macros describe the binary layout of the reloc information we
|
||||
use in a file. */
|
||||
#define RELOC_EXT_BITS_EXTERN_LITTLE 0x80
|
||||
#define RELOC_EXT_BITS_TYPE_LITTLE 3
|
||||
#define RELOC_EXT_BITS_TYPE_SH_LITTLE 0
|
||||
|
||||
#ifndef MY_get_section_contents
|
||||
#define MY_get_section_contents aout_32_get_section_contents
|
||||
#endif
|
||||
|
||||
#define MACHTYPE_OK(mtype) ((mtype) == M_CRIS)
|
||||
|
||||
/* Include generic functions (some are overridden above). */
|
||||
#include "aout32.c"
|
||||
#include "aout-target.h"
|
||||
|
||||
/* We need our own version to set header flags. */
|
||||
|
||||
static bfd_boolean
|
||||
MY(write_object_contents) (abfd)
|
||||
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) (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
struct reloc_ext_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_type;
|
||||
bfd_vma r_addend;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
PUT_WORD (abfd, g->address, natptr->r_address);
|
||||
|
||||
r_type = (unsigned int) g->howto->type;
|
||||
|
||||
r_addend = g->addend;
|
||||
if ((sym->flags & BSF_SECTION_SYM) != 0)
|
||||
r_addend += (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
check for that here. */
|
||||
|
||||
if (bfd_is_abs_section (bfd_get_section (sym)))
|
||||
{
|
||||
r_extern = 0;
|
||||
r_index = N_ABS;
|
||||
}
|
||||
else if ((sym->flags & BSF_SECTION_SYM) == 0)
|
||||
{
|
||||
if (bfd_is_und_section (bfd_get_section (sym))
|
||||
/* Remember to check for weak symbols; they count as global. */
|
||||
|| (sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
|
||||
r_extern = 1;
|
||||
else
|
||||
r_extern = 0;
|
||||
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section. */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
/* The relocation type is the same as the canonical ones, but only
|
||||
the first 3 are used: RELOC_8, RELOC_16, RELOC_32.
|
||||
We may change this later, but assert this for the moment. */
|
||||
if (r_type > 2)
|
||||
{
|
||||
(*_bfd_error_handler) (_("%s: Invalid relocation type exported: %d"),
|
||||
bfd_get_filename (abfd), r_type);
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
}
|
||||
|
||||
/* Now the fun stuff. */
|
||||
natptr->r_index[2] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[0] = r_index;
|
||||
natptr->r_type[0] =
|
||||
(r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
|
||||
| (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
|
||||
|
||||
PUT_WORD (abfd, r_addend, natptr->r_addend);
|
||||
}
|
||||
|
||||
/* We need our own to assert that a normal 8, 16 or 32 reloc is input. */
|
||||
|
||||
static void
|
||||
MY(swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_ext_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount;
|
||||
{
|
||||
unsigned int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_type;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
|
||||
|
||||
/* Now the fun stuff. */
|
||||
r_index = (bytes->r_index[2] << 16)
|
||||
| (bytes->r_index[1] << 8)
|
||||
| bytes->r_index[0];
|
||||
r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
|
||||
r_type = ((bytes->r_type[0]) >> RELOC_EXT_BITS_TYPE_SH_LITTLE)
|
||||
& RELOC_EXT_BITS_TYPE_LITTLE;
|
||||
|
||||
if (r_type > 2)
|
||||
{
|
||||
(*_bfd_error_handler) (_("%B: Invalid relocation type imported: %d"),
|
||||
abfd, r_type);
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
}
|
||||
|
||||
cache_ptr->howto = howto_table_ext + r_type;
|
||||
|
||||
if (r_extern && r_index > symcount)
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: Bad relocation record imported: %d"), abfd, r_index);
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
/* We continue, so we can catch further errors. */
|
||||
r_extern = 0;
|
||||
r_index = N_ABS;
|
||||
}
|
||||
|
||||
/* Magically uses r_extern, symbols etc. Ugly, but it's what's in the
|
||||
default. */
|
||||
MOVE_ADDRESS (GET_SWORD (abfd, bytes->r_addend));
|
||||
}
|
||||
|
||||
/* We use the same as the default, except that we also set
|
||||
"obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;", to avoid changing
|
||||
NAME (aout, set_arch_mach) in aoutx. */
|
||||
|
||||
static bfd_boolean
|
||||
MY(set_sizes) (abfd)
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
239
bfd/aout-encap.c
239
bfd/aout-encap.c
@@ -1,239 +0,0 @@
|
||||
/* BFD back-end for a.out files encapsulated with COFF headers.
|
||||
Copyright 1990, 1991, 1994, 1995, 2000, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* THIS MODULE IS NOT FINISHED. IT PROBABLY DOESN'T EVEN COMPILE. */
|
||||
|
||||
#if 0
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define TEXT_START_ADDR 0
|
||||
#endif
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
const bfd_target *encap_real_callback ();
|
||||
|
||||
const bfd_target *
|
||||
encap_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
|
||||
unsigned long magic; /* Swapped magic number */
|
||||
short coff_magic;
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec exec;
|
||||
bfd_size_type amt = sizeof (magicbuf);
|
||||
|
||||
if (bfd_bread ((PTR) magicbuf, amt, abfd) != amt)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
coff_magic = H_GET_16 (abfd, magicbuf);
|
||||
if (coff_magic != COFF_MAGIC)
|
||||
return 0; /* Not an encap coff file */
|
||||
|
||||
magic = H_GET_32 (abfd, magicbuf);
|
||||
|
||||
if (N_BADMAG (*((struct internal_exec *) &magic)))
|
||||
return 0;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) sizeof (struct coffheader), SEEK_SET) != 0)
|
||||
return 0;
|
||||
|
||||
amt = EXEC_BYTES_SIZE;
|
||||
if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
NAME(aout,swap_exec_header_in) (abfd, &exec_bytes, &exec);
|
||||
|
||||
return aout_32_some_aout_object_p (abfd, &exec, encap_realcallback);
|
||||
}
|
||||
|
||||
/* Finish up the reading of an encapsulated-coff a.out file header. */
|
||||
const bfd_target *
|
||||
encap_real_callback (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
MY(callback) (abfd, execp);
|
||||
|
||||
/* If we have a coff header, it can give us better values for
|
||||
text_start and exec_data_start. This is particularly useful
|
||||
for remote debugging of embedded systems. */
|
||||
if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE)
|
||||
{
|
||||
struct coffheader ch;
|
||||
int val;
|
||||
val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
|
||||
if (val == -1)
|
||||
perror_with_name (filename);
|
||||
val = myread (execchan, &ch, sizeof (ch));
|
||||
if (val < 0)
|
||||
perror_with_name (filename);
|
||||
text_start = ch.text_start;
|
||||
exec_data_start = ch.data_start;
|
||||
}
|
||||
else
|
||||
{
|
||||
text_start =
|
||||
IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
|
||||
exec_data_start = (IS_OBJECT_FILE (exec_aouthdr)
|
||||
? exec_aouthdr.a_text
|
||||
: N_DATADDR (exec_aouthdr));
|
||||
}
|
||||
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); /* FIXME */
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
/* Write an object file in Encapsulated COFF format.
|
||||
Section contents have already been written. We write the
|
||||
file header, symbols, and relocation. */
|
||||
|
||||
bfd_boolean
|
||||
encap_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
bfd_size_type data_pad = 0;
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/* FIXME: Fragments from the old GNU LD program for dealing with
|
||||
encap coff. */
|
||||
struct coffheader coffheader;
|
||||
int need_coff_header;
|
||||
|
||||
/* Determine whether to count the header as part of
|
||||
the text size, and initialize the text size accordingly.
|
||||
This depends on the kind of system and on the output format selected. */
|
||||
|
||||
N_SET_MAGIC (outheader, magic);
|
||||
#ifdef INITIALIZE_HEADER
|
||||
INITIALIZE_HEADER;
|
||||
#endif
|
||||
|
||||
text_size = sizeof (struct exec);
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (relocatable_output == 0 && file_table[0].just_syms_flag == 0)
|
||||
{
|
||||
need_coff_header = 1;
|
||||
/* set this flag now, since it will change the values of N_TXTOFF, etc */
|
||||
N_SET_FLAGS (outheader, aout_backend_info (abfd)->exec_hdr_flags);
|
||||
text_size += sizeof (struct coffheader);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (need_coff_header)
|
||||
{
|
||||
/* We are encapsulating BSD format within COFF format. */
|
||||
struct coffscn *tp, *dp, *bp;
|
||||
|
||||
tp = &coffheader.scns[0];
|
||||
dp = &coffheader.scns[1];
|
||||
bp = &coffheader.scns[2];
|
||||
|
||||
strcpy (tp->s_name, ".text");
|
||||
tp->s_paddr = text_start;
|
||||
tp->s_vaddr = text_start;
|
||||
tp->s_size = text_size;
|
||||
tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec);
|
||||
tp->s_relptr = 0;
|
||||
tp->s_lnnoptr = 0;
|
||||
tp->s_nreloc = 0;
|
||||
tp->s_nlnno = 0;
|
||||
tp->s_flags = 0x20;
|
||||
strcpy (dp->s_name, ".data");
|
||||
dp->s_paddr = data_start;
|
||||
dp->s_vaddr = data_start;
|
||||
dp->s_size = data_size;
|
||||
dp->s_scnptr = tp->s_scnptr + tp->s_size;
|
||||
dp->s_relptr = 0;
|
||||
dp->s_lnnoptr = 0;
|
||||
dp->s_nreloc = 0;
|
||||
dp->s_nlnno = 0;
|
||||
dp->s_flags = 0x40;
|
||||
strcpy (bp->s_name, ".bss");
|
||||
bp->s_paddr = dp->s_vaddr + dp->s_size;
|
||||
bp->s_vaddr = bp->s_paddr;
|
||||
bp->s_size = bss_size;
|
||||
bp->s_scnptr = 0;
|
||||
bp->s_relptr = 0;
|
||||
bp->s_lnnoptr = 0;
|
||||
bp->s_nreloc = 0;
|
||||
bp->s_nlnno = 0;
|
||||
bp->s_flags = 0x80;
|
||||
|
||||
coffheader.f_magic = COFF_MAGIC;
|
||||
coffheader.f_nscns = 3;
|
||||
/* store an unlikely time so programs can
|
||||
* tell that there is a bsd header
|
||||
*/
|
||||
coffheader.f_timdat = 1;
|
||||
coffheader.f_symptr = 0;
|
||||
coffheader.f_nsyms = 0;
|
||||
coffheader.f_opthdr = 28;
|
||||
coffheader.f_flags = 0x103;
|
||||
/* aouthdr */
|
||||
coffheader.magic = ZMAGIC;
|
||||
coffheader.vstamp = 0;
|
||||
coffheader.tsize = tp->s_size;
|
||||
coffheader.dsize = dp->s_size;
|
||||
coffheader.bsize = bp->s_size;
|
||||
coffheader.entry = outheader.a_entry;
|
||||
coffheader.text_start = tp->s_vaddr;
|
||||
coffheader.data_start = dp->s_vaddr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (need_coff_header)
|
||||
mywrite (&coffheader, sizeof coffheader, 1, outdesc);
|
||||
#endif
|
||||
|
||||
#ifndef COFF_ENCAPSULATE
|
||||
padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc);
|
||||
#endif
|
||||
|
||||
text_size -= N_TXTOFF (outheader);
|
||||
WRITE_HEADERS(abfd, execp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define MY_write_object_content encap_write_object_contents
|
||||
#define MY_object_p encap_object_p
|
||||
#define MY_exec_hdr_flags N_FLAGS_COFF_ENCAPSULATE
|
||||
|
||||
#include "aout-target.h"
|
||||
379
bfd/aout-ns32k.c
379
bfd/aout-ns32k.c
@@ -1,379 +0,0 @@
|
||||
/* BFD back-end for ns32k a.out-ish binaries.
|
||||
Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1998, 2000, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Ian Dall (idall@eleceng.adelaide.edu.au).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "aout/aout64.h"
|
||||
#include "ns32k.h"
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MYNS(OP) CONCAT2 (ns32kaout_,OP)
|
||||
|
||||
reloc_howto_type *
|
||||
MYNS(bfd_reloc_type_lookup)
|
||||
PARAMS((bfd *abfd AND
|
||||
bfd_reloc_code_real_type code));
|
||||
|
||||
bfd_boolean
|
||||
MYNS(write_object_contents)
|
||||
PARAMS((bfd *abfd));
|
||||
|
||||
/* Avoid multiple definitions from aoutx if supporting
|
||||
standard a.out format(s) as well as this one. */
|
||||
#define NAME(x,y) CONCAT3 (ns32kaout,_32_,y)
|
||||
|
||||
void bfd_ns32k_arch PARAMS ((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)
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in PARAMS ((bfd *, struct reloc_std_external *,
|
||||
arelent *, asymbol **,
|
||||
bfd_size_type));
|
||||
static void
|
||||
MY_swap_std_reloc_out PARAMS ((bfd *, arelent *,
|
||||
struct reloc_std_external *));
|
||||
reloc_howto_type *
|
||||
MY(reloc_howto) PARAMS ((bfd *, struct reloc_std_external *,
|
||||
int *, int *, int *));
|
||||
void
|
||||
MY(put_reloc) PARAMS ((bfd *, int, int, bfd_vma, reloc_howto_type *,
|
||||
struct reloc_std_external *));
|
||||
|
||||
/* 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)[] =
|
||||
{
|
||||
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
|
||||
/* 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
|
||||
|
||||
reloc_howto_type *
|
||||
MY(reloc_howto) (abfd, rel, r_index, r_extern, r_pcrel)
|
||||
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;
|
||||
|
||||
/* BFD_ASSERT(bfd_header_little_endian (abfd)); */
|
||||
*r_index = ((rel->r_index[2] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[0] );
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
|
||||
*r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||
r_ns32k_type = ((rel->r_type[0] & RELOC_STD_BITS_NS32K_TYPE_LITTLE)
|
||||
>> RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
|
||||
return (MY(howto_table) + r_length + 3 * (*r_pcrel) + 6 * r_ns32k_type);
|
||||
}
|
||||
|
||||
#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
|
||||
MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
|
||||
|
||||
void
|
||||
MY(put_reloc) (abfd, r_extern, r_index, value, howto, reloc)
|
||||
bfd *abfd;
|
||||
int r_extern;
|
||||
int r_index;
|
||||
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;
|
||||
|
||||
/* BFD_ASSERT (bfd_header_little_endian (abfd)); */
|
||||
reloc->r_index[2] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[0] = r_index;
|
||||
reloc->r_type[0] =
|
||||
(r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0)
|
||||
| (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)
|
||||
| (r_ns32k_type << RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
|
||||
}
|
||||
|
||||
#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
|
||||
MY(put_reloc) (BFD, EXT, IDX, VAL, HOWTO, RELOC)
|
||||
|
||||
#define STAT_FOR_EXEC
|
||||
|
||||
#define MY_final_link_relocate _bfd_ns32k_final_link_relocate
|
||||
#define MY_relocate_contents _bfd_ns32k_relocate_contents
|
||||
|
||||
#include "aoutx.h"
|
||||
|
||||
reloc_howto_type *
|
||||
MY(bfd_reloc_type_lookup) (abfd,code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
|
||||
#define ENTRY(i,j) case i: return &MY(howto_table)[j]
|
||||
|
||||
int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
|
||||
|
||||
BFD_ASSERT(ext == 0);
|
||||
if (code == BFD_RELOC_CTOR)
|
||||
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||
{
|
||||
case 32:
|
||||
code = BFD_RELOC_32;
|
||||
break;
|
||||
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 (reloc_howto_type *) NULL;
|
||||
}
|
||||
#undef ENTRY
|
||||
}
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount 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 (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
struct reloc_std_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
int r_extern;
|
||||
unsigned int r_addend;
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
|
||||
/* Name was clobbered by aout_write_syms to be symbol index. */
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
Check for that here. */
|
||||
if (bfd_is_com_section (output_section)
|
||||
|| output_section == &bfd_abs_section
|
||||
|| output_section == &bfd_und_section)
|
||||
{
|
||||
if (bfd_abs_section.symbol == sym)
|
||||
{
|
||||
/* Whoops, looked like an abs symbol, but is really an offset
|
||||
from the abs section. */
|
||||
r_index = 0;
|
||||
r_extern = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fill in symbol. */
|
||||
r_extern = 1;
|
||||
#undef KEEPIT
|
||||
#define KEEPIT udata.i
|
||||
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||
#undef KEEPIT
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section. */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
MY_put_reloc (abfd, r_extern, r_index, g->address, g->howto, natptr);
|
||||
}
|
||||
|
||||
bfd_reloc_status_type
|
||||
_bfd_ns32k_relocate_contents (howto, input_bfd, relocation, location)
|
||||
reloc_howto_type *howto;
|
||||
bfd *input_bfd;
|
||||
bfd_vma relocation;
|
||||
bfd_byte *location;
|
||||
{
|
||||
int r_ns32k_type = (howto - MY(howto_table)) / 6;
|
||||
bfd_vma (*get_data) PARAMS ((bfd_byte *, int));
|
||||
void (*put_data) PARAMS ((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);
|
||||
/* NOT REACHED */
|
||||
break;
|
||||
default:
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
return _bfd_do_ns32k_reloc_contents (howto, input_bfd, relocation,
|
||||
location, get_data, put_data);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/* BFD backend for sparc little-endian aout binaries.
|
||||
Copyright 1996, 2001 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGETNAME "a.out-sparc-little"
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MY(OP) CONCAT2 (sparcle_aout_,OP)
|
||||
|
||||
#include "bfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "libaout.h"
|
||||
|
||||
#define MACHTYPE_OK(mtype) ((mtype) == M_SPARC || (mtype) == M_SPARCLET)
|
||||
|
||||
/* Include the usual a.out support. */
|
||||
#define TARGET_IS_LITTLE_ENDIAN_P
|
||||
#include "aoutf1.h"
|
||||
@@ -1,681 +0,0 @@
|
||||
/* Define a target vector and some small routines for a variant of a.out.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
/*#include "libaout.h"*/
|
||||
|
||||
#ifndef SEGMENT_SIZE
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#endif
|
||||
|
||||
extern reloc_howto_type * NAME(aout,reloc_type_lookup)
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
|
||||
/* 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) PARAMS ((bfd *));
|
||||
|
||||
static const bfd_target *
|
||||
MY(callback) (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
unsigned int arch_align_power;
|
||||
unsigned long arch_align;
|
||||
|
||||
/* Calculate the file positions of the parts of a newly read aout header */
|
||||
obj_textsec (abfd)->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. */
|
||||
#if 0
|
||||
adata(abfd).page_size = TARGET_PAGE_SIZE;
|
||||
adata(abfd).segment_size = SEGMENT_SIZE;
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
#endif
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MY_object_p
|
||||
/* Finish up the reading of an a.out file header */
|
||||
|
||||
static const bfd_target *MY(object_p) PARAMS ((bfd *));
|
||||
|
||||
static const bfd_target *
|
||||
MY(object_p) (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec exec_bytes; /* Raw exec header from file */
|
||||
struct internal_exec exec; /* Cleaned-up exec header */
|
||||
const bfd_target *target;
|
||||
bfd_size_type amt = EXEC_BYTES_SIZE;
|
||||
|
||||
if (bfd_bread ((PTR) &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 /* SWAP_MAGIC */
|
||||
|
||||
if (N_BADMAG (exec)) return 0;
|
||||
#ifdef MACHTYPE_OK
|
||||
if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) return 0;
|
||||
#endif
|
||||
|
||||
NAME(aout,swap_exec_header_in) (abfd, &exec_bytes, &exec);
|
||||
|
||||
#ifdef SWAP_MAGIC
|
||||
/* swap_exec_header_in read in a_info with the wrong byte order */
|
||||
exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
|
||||
#endif /* SWAP_MAGIC */
|
||||
|
||||
target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
|
||||
|
||||
#ifdef ENTRY_CAN_BE_ZERO
|
||||
/* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
|
||||
* means that it isn't obvious if EXEC_P should be set.
|
||||
* All of the following must be true for an executable:
|
||||
* There must be no relocations, the bfd can be neither an
|
||||
* archive nor an archive element, and the file must be executable. */
|
||||
|
||||
if (exec.a_trsize + exec.a_drsize == 0
|
||||
&& bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
|
||||
{
|
||||
struct stat buf;
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR 0100 /* Execute by owner. */
|
||||
#endif
|
||||
if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
|
||||
abfd->flags |= EXEC_P;
|
||||
}
|
||||
#endif /* ENTRY_CAN_BE_ZERO */
|
||||
|
||||
return target;
|
||||
}
|
||||
#define MY_object_p MY(object_p)
|
||||
#endif
|
||||
|
||||
#ifndef MY_mkobject
|
||||
|
||||
static bfd_boolean MY(mkobject) PARAMS ((bfd *));
|
||||
|
||||
static bfd_boolean
|
||||
MY(mkobject) (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (! NAME(aout,mkobject) (abfd))
|
||||
return FALSE;
|
||||
#if 0 /* Sizes get set in set_sizes callback, later, after we know
|
||||
the architecture and machine. */
|
||||
adata(abfd).page_size = TARGET_PAGE_SIZE;
|
||||
adata(abfd).segment_size = SEGMENT_SIZE;
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
#define MY_mkobject MY(mkobject)
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_copy_private_section_data
|
||||
|
||||
/* Copy private section data. This actually does nothing with the
|
||||
sections. It copies the subformat field. We copy it here, because
|
||||
we need to know whether this is a QMAGIC file before we set the
|
||||
section contents, and copy_private_bfd_data is not called until
|
||||
after the section contents have been set. */
|
||||
|
||||
static bfd_boolean MY_bfd_copy_private_section_data
|
||||
PARAMS ((bfd *, asection *, bfd *, asection *));
|
||||
|
||||
static bfd_boolean
|
||||
MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
|
||||
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) PARAMS ((bfd *));
|
||||
|
||||
static bfd_boolean
|
||||
MY(write_object_contents) (abfd)
|
||||
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) PARAMS ((bfd *));
|
||||
|
||||
static bfd_boolean
|
||||
MY(set_sizes) (abfd)
|
||||
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
|
||||
PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
|
||||
|
||||
static void
|
||||
MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff)
|
||||
bfd *abfd;
|
||||
file_ptr *ptreloff;
|
||||
file_ptr *pdreloff;
|
||||
file_ptr *psymoff;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
*ptreloff = N_TRELOFF (*execp);
|
||||
*pdreloff = N_DRELOFF (*execp);
|
||||
*psymoff = N_SYMOFF (*execp);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_final_link
|
||||
|
||||
/* Final link routine. We need to use a call back to get the correct
|
||||
offsets in the output file. */
|
||||
|
||||
static bfd_boolean MY_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *));
|
||||
|
||||
static bfd_boolean
|
||||
MY_bfd_final_link (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* We assume BFD generic archive files. */
|
||||
#ifndef MY_openr_next_archived_file
|
||||
#define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
|
||||
#endif
|
||||
#ifndef MY_get_elt_at_index
|
||||
#define MY_get_elt_at_index _bfd_generic_get_elt_at_index
|
||||
#endif
|
||||
#ifndef MY_generic_stat_arch_elt
|
||||
#define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
|
||||
#endif
|
||||
#ifndef MY_slurp_armap
|
||||
#define MY_slurp_armap bfd_slurp_bsd_armap
|
||||
#endif
|
||||
#ifndef MY_slurp_extended_name_table
|
||||
#define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
|
||||
#endif
|
||||
#ifndef MY_construct_extended_name_table
|
||||
#define MY_construct_extended_name_table \
|
||||
_bfd_archive_bsd_construct_extended_name_table
|
||||
#endif
|
||||
#ifndef MY_write_armap
|
||||
#define MY_write_armap bsd_write_armap
|
||||
#endif
|
||||
#ifndef MY_read_ar_hdr
|
||||
#define MY_read_ar_hdr _bfd_generic_read_ar_hdr
|
||||
#endif
|
||||
#ifndef MY_truncate_arname
|
||||
#define MY_truncate_arname bfd_bsd_truncate_arname
|
||||
#endif
|
||||
#ifndef MY_update_armap_timestamp
|
||||
#define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
|
||||
#endif
|
||||
|
||||
/* No core file defined here -- configure in trad-core.c separately. */
|
||||
#ifndef MY_core_file_failing_command
|
||||
#define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
|
||||
#endif
|
||||
#ifndef MY_core_file_failing_signal
|
||||
#define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
|
||||
#endif
|
||||
#ifndef MY_core_file_matches_executable_p
|
||||
#define MY_core_file_matches_executable_p \
|
||||
_bfd_nocore_core_file_matches_executable_p
|
||||
#endif
|
||||
#ifndef MY_core_file_p
|
||||
#define MY_core_file_p _bfd_dummy_target
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_debug_info_start
|
||||
#define MY_bfd_debug_info_start bfd_void
|
||||
#endif
|
||||
#ifndef MY_bfd_debug_info_end
|
||||
#define MY_bfd_debug_info_end bfd_void
|
||||
#endif
|
||||
#ifndef MY_bfd_debug_info_accumulate
|
||||
#define MY_bfd_debug_info_accumulate \
|
||||
(void (*) PARAMS ((bfd*, struct bfd_section *))) bfd_void
|
||||
#endif
|
||||
|
||||
#ifndef MY_core_file_failing_command
|
||||
#define MY_core_file_failing_command NAME(aout,core_file_failing_command)
|
||||
#endif
|
||||
#ifndef MY_core_file_failing_signal
|
||||
#define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
|
||||
#endif
|
||||
#ifndef MY_core_file_matches_executable_p
|
||||
#define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
|
||||
#endif
|
||||
#ifndef MY_set_section_contents
|
||||
#define MY_set_section_contents NAME(aout,set_section_contents)
|
||||
#endif
|
||||
#ifndef MY_get_section_contents
|
||||
#define MY_get_section_contents NAME(aout,get_section_contents)
|
||||
#endif
|
||||
#ifndef MY_get_section_contents_in_window
|
||||
#define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
|
||||
#endif
|
||||
#ifndef MY_new_section_hook
|
||||
#define MY_new_section_hook NAME(aout,new_section_hook)
|
||||
#endif
|
||||
#ifndef MY_get_symtab_upper_bound
|
||||
#define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
|
||||
#endif
|
||||
#ifndef MY_canonicalize_symtab
|
||||
#define MY_canonicalize_symtab NAME(aout,canonicalize_symtab)
|
||||
#endif
|
||||
#ifndef MY_get_reloc_upper_bound
|
||||
#define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
|
||||
#endif
|
||||
#ifndef MY_canonicalize_reloc
|
||||
#define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
|
||||
#endif
|
||||
#ifndef MY_make_empty_symbol
|
||||
#define MY_make_empty_symbol NAME(aout,make_empty_symbol)
|
||||
#endif
|
||||
#ifndef MY_print_symbol
|
||||
#define MY_print_symbol NAME(aout,print_symbol)
|
||||
#endif
|
||||
#ifndef MY_get_symbol_info
|
||||
#define MY_get_symbol_info NAME(aout,get_symbol_info)
|
||||
#endif
|
||||
#ifndef MY_get_lineno
|
||||
#define MY_get_lineno NAME(aout,get_lineno)
|
||||
#endif
|
||||
#ifndef MY_set_arch_mach
|
||||
#define MY_set_arch_mach NAME(aout,set_arch_mach)
|
||||
#endif
|
||||
#ifndef MY_find_nearest_line
|
||||
#define MY_find_nearest_line NAME(aout,find_nearest_line)
|
||||
#endif
|
||||
#ifndef MY_sizeof_headers
|
||||
#define MY_sizeof_headers NAME(aout,sizeof_headers)
|
||||
#endif
|
||||
#ifndef MY_bfd_get_relocated_section_contents
|
||||
#define MY_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#endif
|
||||
#ifndef MY_bfd_relax_section
|
||||
#define MY_bfd_relax_section bfd_generic_relax_section
|
||||
#endif
|
||||
#ifndef MY_bfd_gc_sections
|
||||
#define MY_bfd_gc_sections bfd_generic_gc_sections
|
||||
#endif
|
||||
#ifndef MY_bfd_merge_sections
|
||||
#define MY_bfd_merge_sections bfd_generic_merge_sections
|
||||
#endif
|
||||
#ifndef MY_bfd_is_group_section
|
||||
#define MY_bfd_is_group_section bfd_generic_is_group_section
|
||||
#endif
|
||||
#ifndef MY_bfd_discard_group
|
||||
#define MY_bfd_discard_group bfd_generic_discard_group
|
||||
#endif
|
||||
#ifndef MY_section_already_linked
|
||||
#define MY_section_already_linked \
|
||||
_bfd_generic_section_already_linked
|
||||
#endif
|
||||
#ifndef MY_bfd_reloc_type_lookup
|
||||
#define MY_bfd_reloc_type_lookup NAME(aout,reloc_type_lookup)
|
||||
#endif
|
||||
#ifndef MY_bfd_make_debug_symbol
|
||||
#define MY_bfd_make_debug_symbol 0
|
||||
#endif
|
||||
#ifndef MY_read_minisymbols
|
||||
#define MY_read_minisymbols NAME(aout,read_minisymbols)
|
||||
#endif
|
||||
#ifndef MY_minisymbol_to_symbol
|
||||
#define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol)
|
||||
#endif
|
||||
#ifndef MY_bfd_link_hash_table_create
|
||||
#define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
|
||||
#endif
|
||||
#ifndef MY_bfd_link_hash_table_free
|
||||
#define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
|
||||
#endif
|
||||
#ifndef MY_bfd_link_add_symbols
|
||||
#define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
|
||||
#endif
|
||||
#ifndef MY_bfd_link_just_syms
|
||||
#define MY_bfd_link_just_syms _bfd_generic_link_just_syms
|
||||
#endif
|
||||
#ifndef MY_bfd_link_split_section
|
||||
#define MY_bfd_link_split_section _bfd_generic_link_split_section
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_copy_private_bfd_data
|
||||
#define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_merge_private_bfd_data
|
||||
#define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_copy_private_symbol_data
|
||||
#define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_copy_private_header_data
|
||||
#define MY_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_print_private_bfd_data
|
||||
#define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_set_private_flags
|
||||
#define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_is_local_label_name
|
||||
#define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_is_target_special_symbol
|
||||
#define MY_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_free_cached_info
|
||||
#define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
|
||||
#endif
|
||||
|
||||
#ifndef MY_close_and_cleanup
|
||||
#define MY_close_and_cleanup MY_bfd_free_cached_info
|
||||
#endif
|
||||
|
||||
#ifndef MY_get_dynamic_symtab_upper_bound
|
||||
#define MY_get_dynamic_symtab_upper_bound \
|
||||
_bfd_nodynamic_get_dynamic_symtab_upper_bound
|
||||
#endif
|
||||
#ifndef MY_canonicalize_dynamic_symtab
|
||||
#define MY_canonicalize_dynamic_symtab \
|
||||
_bfd_nodynamic_canonicalize_dynamic_symtab
|
||||
#endif
|
||||
#ifndef MY_get_synthetic_symtab
|
||||
#define MY_get_synthetic_symtab \
|
||||
_bfd_nodynamic_get_synthetic_symtab
|
||||
#endif
|
||||
#ifndef MY_get_dynamic_reloc_upper_bound
|
||||
#define MY_get_dynamic_reloc_upper_bound \
|
||||
_bfd_nodynamic_get_dynamic_reloc_upper_bound
|
||||
#endif
|
||||
#ifndef MY_canonicalize_dynamic_reloc
|
||||
#define MY_canonicalize_dynamic_reloc \
|
||||
_bfd_nodynamic_canonicalize_dynamic_reloc
|
||||
#endif
|
||||
|
||||
/* Aout symbols normally have leading underscores */
|
||||
#ifndef MY_symbol_leading_char
|
||||
#define MY_symbol_leading_char '_'
|
||||
#endif
|
||||
|
||||
/* Aout archives normally use spaces for padding */
|
||||
#ifndef AR_PAD_CHAR
|
||||
#define AR_PAD_CHAR ' '
|
||||
#endif
|
||||
|
||||
#ifndef MY_BFD_TARGET
|
||||
const bfd_target MY(vec) =
|
||||
{
|
||||
TARGETNAME, /* name */
|
||||
bfd_target_aout_flavour,
|
||||
#ifdef TARGET_IS_BIG_ENDIAN_P
|
||||
BFD_ENDIAN_BIG, /* target byte order (big) */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order (big) */
|
||||
#else
|
||||
BFD_ENDIAN_LITTLE, /* target byte order (little) */
|
||||
BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
|
||||
#endif
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
|
||||
MY_symbol_leading_char,
|
||||
AR_PAD_CHAR, /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
#ifdef TARGET_IS_BIG_ENDIAN_P
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
#else
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
#endif
|
||||
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, MY_core_file_p},
|
||||
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (MY),
|
||||
BFD_JUMP_TABLE_COPY (MY),
|
||||
BFD_JUMP_TABLE_CORE (MY),
|
||||
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||
BFD_JUMP_TABLE_RELOCS (MY),
|
||||
BFD_JUMP_TABLE_WRITE (MY),
|
||||
BFD_JUMP_TABLE_LINK (MY),
|
||||
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||
|
||||
/* Alternative_target */
|
||||
NULL,
|
||||
|
||||
(PTR) MY_backend_data
|
||||
};
|
||||
#endif /* MY_BFD_TARGET */
|
||||
1123
bfd/aout-tic30.c
1123
bfd/aout-tic30.c
File diff suppressed because it is too large
Load Diff
37
bfd/aout0.c
37
bfd/aout0.c
@@ -1,37 +0,0 @@
|
||||
/* BFD backend for SunOS style a.out with flags set to 0
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 2001
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGETNAME "a.out-zero-big"
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MY(OP) CONCAT2 (aout0_big_,OP)
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
#define MY_exec_hdr_flags 0
|
||||
|
||||
#define MACHTYPE_OK(mtype) \
|
||||
((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020)
|
||||
|
||||
/* Include the usual a.out support. */
|
||||
#include "aoutf1.h"
|
||||
23
bfd/aout32.c
23
bfd/aout32.c
@@ -1,23 +0,0 @@
|
||||
/* BFD back-end for 32-bit a.out files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define ARCH_SIZE 32
|
||||
|
||||
#include "aoutx.h"
|
||||
31
bfd/aout64.c
31
bfd/aout64.c
@@ -1,31 +0,0 @@
|
||||
/* BFD back-end for 64-bit a.out files.
|
||||
Copyright 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define 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"
|
||||
846
bfd/aoutf1.h
846
bfd/aoutf1.h
@@ -1,846 +0,0 @@
|
||||
/* A.out "format 1" file handling code for BFD.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
|
||||
2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "aout/sun4.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
|
||||
/* This is needed to reject a NewsOS file, e.g. in
|
||||
gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
|
||||
I needed to add M_UNKNOWN to recognize a 68000 object, so this will
|
||||
probably no longer reject a NewsOS object. <ian@cygnus.com>. */
|
||||
#ifndef MACHTYPE_OK
|
||||
#define MACHTYPE_OK(mtype) \
|
||||
(((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
|
||||
|| (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
|
||||
&& bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
|
||||
#endif
|
||||
|
||||
/*
|
||||
The file @code{aoutf1.h} contains the code for BFD's
|
||||
a.out back end. Control over the generated back end is given by these
|
||||
two preprocessor names:
|
||||
@table @code
|
||||
@item ARCH_SIZE
|
||||
This value should be either 32 or 64, depending upon the size of an
|
||||
int in the target format. It changes the sizes of the structs which
|
||||
perform the memory/disk mapping of structures.
|
||||
|
||||
The 64 bit backend may only be used if the host compiler supports 64
|
||||
ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
|
||||
With this name defined, @emph{all} bfd operations are performed with 64bit
|
||||
arithmetic, not just those to a 64bit target.
|
||||
|
||||
@item TARGETNAME
|
||||
The name put into the target vector.
|
||||
@item
|
||||
@end table
|
||||
|
||||
*/
|
||||
|
||||
/*SUPPRESS558*/
|
||||
/*SUPPRESS529*/
|
||||
|
||||
#if ARCH_SIZE == 64
|
||||
#define sunos_set_arch_mach sunos_64_set_arch_mach
|
||||
#define sunos_write_object_contents aout_64_sunos4_write_object_contents
|
||||
#else
|
||||
#define sunos_set_arch_mach sunos_32_set_arch_mach
|
||||
#define sunos_write_object_contents aout_32_sunos4_write_object_contents
|
||||
#endif
|
||||
|
||||
static bfd_boolean sunos_merge_private_bfd_data
|
||||
PARAMS ((bfd *, bfd *));
|
||||
static void sunos_set_arch_mach
|
||||
PARAMS ((bfd *, enum machine_type));
|
||||
static void choose_reloc_size
|
||||
PARAMS ((bfd *));
|
||||
static bfd_boolean sunos_write_object_contents
|
||||
PARAMS ((bfd *));
|
||||
static const bfd_target *sunos4_core_file_p
|
||||
PARAMS ((bfd *));
|
||||
static char *sunos4_core_file_failing_command
|
||||
PARAMS ((bfd *));
|
||||
static int sunos4_core_file_failing_signal
|
||||
PARAMS ((bfd *));
|
||||
static bfd_boolean sunos4_core_file_matches_executable_p
|
||||
PARAMS ((bfd *, bfd *));
|
||||
static bfd_boolean sunos4_set_sizes
|
||||
PARAMS ((bfd *));
|
||||
|
||||
/* Merge backend data into the output file.
|
||||
This is necessary on sparclet-aout where we want the resultant machine
|
||||
number to be M_SPARCLET if any input file is M_SPARCLET. */
|
||||
|
||||
#define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data
|
||||
|
||||
static bfd_boolean
|
||||
sunos_merge_private_bfd_data (ibfd, obfd)
|
||||
bfd *ibfd, *obfd;
|
||||
{
|
||||
if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour
|
||||
|| bfd_get_flavour (obfd) != bfd_target_aout_flavour)
|
||||
return TRUE;
|
||||
|
||||
if (bfd_get_arch (obfd) == bfd_arch_sparc)
|
||||
{
|
||||
if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
|
||||
bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach,
|
||||
depending upon ARCH_SIZE. */
|
||||
|
||||
static void
|
||||
sunos_set_arch_mach (abfd, machtype)
|
||||
bfd *abfd;
|
||||
enum machine_type machtype;
|
||||
{
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
switch (machtype)
|
||||
{
|
||||
|
||||
case M_UNKNOWN:
|
||||
/* Some Sun3s make magic numbers without cpu types in them, so
|
||||
we'll default to the 68000. */
|
||||
arch = bfd_arch_m68k;
|
||||
machine = bfd_mach_m68000;
|
||||
break;
|
||||
|
||||
case M_68010:
|
||||
case M_HP200:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = bfd_mach_m68010;
|
||||
break;
|
||||
|
||||
case M_68020:
|
||||
case M_HP300:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = bfd_mach_m68020;
|
||||
break;
|
||||
|
||||
case M_SPARC:
|
||||
arch = bfd_arch_sparc;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_SPARCLET:
|
||||
arch = bfd_arch_sparc;
|
||||
machine = bfd_mach_sparc_sparclet;
|
||||
break;
|
||||
|
||||
case M_SPARCLITE_LE:
|
||||
arch = bfd_arch_sparc;
|
||||
machine = bfd_mach_sparc_sparclite_le;
|
||||
break;
|
||||
|
||||
case M_386:
|
||||
case M_386_DYNIX:
|
||||
arch = bfd_arch_i386;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_29K:
|
||||
arch = bfd_arch_a29k;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_HPUX:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
arch = bfd_arch_obscure;
|
||||
machine = 0;
|
||||
break;
|
||||
}
|
||||
bfd_set_arch_mach (abfd, arch, machine);
|
||||
}
|
||||
|
||||
#define SET_ARCH_MACH(ABFD, EXEC) \
|
||||
NAME(sunos,set_arch_mach) (ABFD, N_MACHTYPE (EXEC)); \
|
||||
choose_reloc_size(ABFD);
|
||||
|
||||
/* Determine the size of a relocation entry, based on the architecture */
|
||||
static void
|
||||
choose_reloc_size (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
case bfd_arch_sparc:
|
||||
case bfd_arch_a29k:
|
||||
obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
|
||||
break;
|
||||
default:
|
||||
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write an object file in SunOS format. Section contents have
|
||||
already been written. We write the file header, symbols, and
|
||||
relocation. The real name of this function is either
|
||||
aout_64_sunos4_write_object_contents or
|
||||
aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE. */
|
||||
|
||||
static bfd_boolean
|
||||
sunos_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/* Magic number, maestro, please! */
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
case bfd_arch_m68k:
|
||||
switch (bfd_get_mach (abfd))
|
||||
{
|
||||
case bfd_mach_m68000:
|
||||
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||
break;
|
||||
case bfd_mach_m68010:
|
||||
N_SET_MACHTYPE (*execp, M_68010);
|
||||
break;
|
||||
default:
|
||||
case bfd_mach_m68020:
|
||||
N_SET_MACHTYPE (*execp, M_68020);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case bfd_arch_sparc:
|
||||
switch (bfd_get_mach (abfd))
|
||||
{
|
||||
case bfd_mach_sparc_sparclet:
|
||||
N_SET_MACHTYPE (*execp, M_SPARCLET);
|
||||
break;
|
||||
case bfd_mach_sparc_sparclite_le:
|
||||
N_SET_MACHTYPE (*execp, M_SPARCLITE_LE);
|
||||
break;
|
||||
default:
|
||||
N_SET_MACHTYPE (*execp, M_SPARC);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case bfd_arch_i386:
|
||||
N_SET_MACHTYPE (*execp, M_386);
|
||||
break;
|
||||
case bfd_arch_a29k:
|
||||
N_SET_MACHTYPE (*execp, M_29K);
|
||||
break;
|
||||
default:
|
||||
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||
}
|
||||
|
||||
choose_reloc_size (abfd);
|
||||
|
||||
N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
|
||||
|
||||
N_SET_DYNAMIC (*execp, (long)(bfd_get_file_flags (abfd) & DYNAMIC));
|
||||
|
||||
WRITE_HEADERS (abfd, execp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* core files */
|
||||
|
||||
#define CORE_MAGIC 0x080456
|
||||
#define CORE_NAMELEN 16
|
||||
|
||||
/* The core structure is taken from the Sun documentation.
|
||||
Unfortunately, they don't document the FPA structure, or at least I
|
||||
can't find it easily. Fortunately the core header contains its own
|
||||
length. So this shouldn't cause problems, except for c_ucode, which
|
||||
so far we don't use but is easy to find with a little arithmetic. */
|
||||
|
||||
/* But the reg structure can be gotten from the SPARC processor handbook.
|
||||
This really should be in a GNU include file though so that gdb can use
|
||||
the same info. */
|
||||
struct regs
|
||||
{
|
||||
int r_psr;
|
||||
int r_pc;
|
||||
int r_npc;
|
||||
int r_y;
|
||||
int r_g1;
|
||||
int r_g2;
|
||||
int r_g3;
|
||||
int r_g4;
|
||||
int r_g5;
|
||||
int r_g6;
|
||||
int r_g7;
|
||||
int r_o0;
|
||||
int r_o1;
|
||||
int r_o2;
|
||||
int r_o3;
|
||||
int r_o4;
|
||||
int r_o5;
|
||||
int r_o6;
|
||||
int r_o7;
|
||||
};
|
||||
|
||||
/* Taken from Sun documentation: */
|
||||
|
||||
/* FIXME: It's worse than we expect. This struct contains TWO substructs
|
||||
neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't
|
||||
even portably access the stuff in between! */
|
||||
|
||||
struct external_sparc_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SPARC_CORE_LEN 432
|
||||
int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
|
||||
struct external_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
/* Core files generated by the BCP (the part of Solaris which allows
|
||||
it to run SunOS4 a.out files). */
|
||||
struct external_solaris_bcp_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SOLARIS_BCP_CORE_LEN 456
|
||||
int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
|
||||
int c_exdata_vp; /* exdata structure */
|
||||
int c_exdata_tsize;
|
||||
int c_exdata_dsize;
|
||||
int c_exdata_bsize;
|
||||
int c_exdata_lsize;
|
||||
int c_exdata_nshlibs;
|
||||
short c_exdata_mach;
|
||||
short c_exdata_mag;
|
||||
int c_exdata_toffset;
|
||||
int c_exdata_doffset;
|
||||
int c_exdata_loffset;
|
||||
int c_exdata_txtorg;
|
||||
int c_exdata_datorg;
|
||||
int c_exdata_entloc;
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
struct external_sun3_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */
|
||||
int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */
|
||||
struct external_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
struct internal_sunos_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
long c_regs_pos; /* file offset of General purpose registers */
|
||||
int c_regs_size; /* size of General purpose registers */
|
||||
struct internal_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
bfd_vma c_data_addr; /* Data start (address) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
bfd_vma c_stacktop; /* Stack top (address) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
long fp_stuff_pos; /* file offset of external FPU state (regs) */
|
||||
int fp_stuff_size; /* Size of it */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
};
|
||||
|
||||
static void swapcore_sun3
|
||||
PARAMS ((bfd *, char *, struct internal_sunos_core *));
|
||||
static void swapcore_sparc
|
||||
PARAMS ((bfd *, char *, struct internal_sunos_core *));
|
||||
static void swapcore_solaris_bcp
|
||||
PARAMS ((bfd *, char *, struct internal_sunos_core *));
|
||||
|
||||
/* byte-swap in the Sun-3 core structure */
|
||||
static void
|
||||
swapcore_sun3 (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
|
||||
|
||||
intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
|
||||
intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
#if ARCH_SIZE == 64
|
||||
aout_64_swap_exec_header_in
|
||||
#else
|
||||
aout_32_swap_exec_header_in
|
||||
#endif
|
||||
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
|
||||
intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
|
||||
intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
|
||||
intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
|
||||
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||
intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode = H_GET_32 (abfd,
|
||||
(intcore->c_len
|
||||
- sizeof (extcore->c_ucode)
|
||||
+ (unsigned char *) extcore));
|
||||
intcore->c_stacktop = 0x0E000000; /* By experimentation */
|
||||
}
|
||||
|
||||
/* byte-swap in the Sparc core structure */
|
||||
static void
|
||||
swapcore_sparc (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
|
||||
|
||||
intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
|
||||
intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
#if ARCH_SIZE == 64
|
||||
aout_64_swap_exec_header_in
|
||||
#else
|
||||
aout_32_swap_exec_header_in
|
||||
#endif
|
||||
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
|
||||
intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
|
||||
intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
|
||||
intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
|
||||
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||
intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode = H_GET_32 (abfd,
|
||||
(intcore->c_len
|
||||
- sizeof (extcore->c_ucode)
|
||||
+ (unsigned char *) extcore));
|
||||
|
||||
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||
Presuming that this remains true, this definition will work. */
|
||||
/* Now sun has provided us with another challenge. The value is different
|
||||
for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
|
||||
the other based on the current value of the stack pointer. This
|
||||
loses (a) if the stack pointer has been clobbered, or (b) if the stack
|
||||
is larger than 128 megabytes.
|
||||
|
||||
It's times like these you're glad they're switching to ELF.
|
||||
|
||||
Note that using include files or nlist on /vmunix would be wrong,
|
||||
because we want the value for this core file, no matter what kind of
|
||||
machine we were compiled on or are running on. */
|
||||
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
|
||||
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
|
||||
{
|
||||
bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
|
||||
if (sp < SPARC_USRSTACK_SPARC10)
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
|
||||
else
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
|
||||
}
|
||||
}
|
||||
|
||||
/* byte-swap in the Solaris BCP core structure */
|
||||
static void
|
||||
swapcore_solaris_bcp (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_solaris_bcp_core *extcore =
|
||||
(struct external_solaris_bcp_core *) ext;
|
||||
|
||||
intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
|
||||
intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
|
||||
/* The Solaris BCP exdata structure does not contain an a_syms field,
|
||||
so we are unable to synthesize an internal exec header.
|
||||
Luckily we are able to figure out the start address of the data section,
|
||||
which is the only thing needed from the internal exec header,
|
||||
from the exdata structure.
|
||||
|
||||
As of Solaris 2.3, BCP core files for statically linked executables
|
||||
are buggy. The exdata structure is not properly filled in, and
|
||||
the data section is written from address zero instead of the data
|
||||
start address. */
|
||||
memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
|
||||
intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg);
|
||||
intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
|
||||
intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
|
||||
intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
|
||||
intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos =
|
||||
(long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode = H_GET_32 (abfd,
|
||||
(intcore->c_len
|
||||
- sizeof (extcore->c_ucode)
|
||||
+ (unsigned char *) extcore));
|
||||
|
||||
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||
Presuming that this remains true, this definition will work. */
|
||||
/* Now sun has provided us with another challenge. The value is different
|
||||
for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
|
||||
the other based on the current value of the stack pointer. This
|
||||
loses (a) if the stack pointer has been clobbered, or (b) if the stack
|
||||
is larger than 128 megabytes.
|
||||
|
||||
It's times like these you're glad they're switching to ELF.
|
||||
|
||||
Note that using include files or nlist on /vmunix would be wrong,
|
||||
because we want the value for this core file, no matter what kind of
|
||||
machine we were compiled on or are running on. */
|
||||
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
|
||||
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
|
||||
{
|
||||
bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
|
||||
if (sp < SPARC_USRSTACK_SPARC10)
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
|
||||
else
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
|
||||
}
|
||||
}
|
||||
|
||||
/* need this cast because ptr is really void * */
|
||||
#define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
|
||||
#define core_datasec(bfd) (core_hdr(bfd)->data_section)
|
||||
#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
|
||||
#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
|
||||
#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)
|
||||
|
||||
/* These are stored in the bfd's tdata */
|
||||
struct sun_core_struct
|
||||
{
|
||||
struct internal_sunos_core *hdr; /* core file header */
|
||||
asection *data_section;
|
||||
asection *stack_section;
|
||||
asection *reg_section;
|
||||
asection *reg2_section;
|
||||
};
|
||||
|
||||
static const bfd_target *
|
||||
sunos4_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||
bfd_size_type core_size, amt;
|
||||
unsigned long core_mag;
|
||||
struct internal_sunos_core *core;
|
||||
char *extcore;
|
||||
struct mergem
|
||||
{
|
||||
struct sun_core_struct suncoredata;
|
||||
struct internal_sunos_core internal_sunos_core;
|
||||
char external_core[1];
|
||||
} *mergem;
|
||||
|
||||
if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
|
||||
!= sizeof (longbuf))
|
||||
return 0;
|
||||
core_mag = H_GET_32 (abfd, longbuf);
|
||||
|
||||
if (core_mag != CORE_MAGIC)
|
||||
return 0;
|
||||
|
||||
/* SunOS core headers can vary in length; second word is size; */
|
||||
if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
|
||||
!= sizeof (longbuf))
|
||||
return 0;
|
||||
core_size = H_GET_32 (abfd, longbuf);
|
||||
/* Sanity check */
|
||||
if (core_size > 20000)
|
||||
return 0;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
|
||||
return 0;
|
||||
|
||||
amt = core_size + sizeof (struct mergem);
|
||||
mergem = (struct mergem *) bfd_zalloc (abfd, amt);
|
||||
if (mergem == NULL)
|
||||
return 0;
|
||||
|
||||
extcore = mergem->external_core;
|
||||
|
||||
if ((bfd_bread ((PTR) extcore, core_size, abfd)) != core_size)
|
||||
{
|
||||
loser:
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
abfd->tdata.any = NULL;
|
||||
bfd_section_list_clear (abfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Validate that it's a core file we know how to handle, due to sun
|
||||
botching the positioning of registers and other fields in a machine
|
||||
dependent way. */
|
||||
core = &mergem->internal_sunos_core;
|
||||
switch (core_size)
|
||||
{
|
||||
case SPARC_CORE_LEN:
|
||||
swapcore_sparc (abfd, extcore, core);
|
||||
break;
|
||||
case SUN3_CORE_LEN:
|
||||
swapcore_sun3 (abfd, extcore, core);
|
||||
break;
|
||||
case SOLARIS_BCP_CORE_LEN:
|
||||
swapcore_solaris_bcp (abfd, extcore, core);
|
||||
break;
|
||||
default:
|
||||
bfd_set_error (bfd_error_system_call); /* FIXME */
|
||||
goto loser;
|
||||
}
|
||||
|
||||
abfd->tdata.sun_core_data = &mergem->suncoredata;
|
||||
abfd->tdata.sun_core_data->hdr = core;
|
||||
|
||||
/* Create the sections. */
|
||||
core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack");
|
||||
if (core_stacksec (abfd) == NULL)
|
||||
/* bfd_release frees everything allocated after it's arg. */
|
||||
goto loser;
|
||||
|
||||
core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data");
|
||||
if (core_datasec (abfd) == NULL)
|
||||
goto loser;
|
||||
|
||||
core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
|
||||
if (core_regsec (abfd) == NULL)
|
||||
goto loser;
|
||||
|
||||
core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2");
|
||||
if (core_reg2sec (abfd) == NULL)
|
||||
goto loser;
|
||||
|
||||
core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
|
||||
core_stacksec (abfd)->size = core->c_ssize;
|
||||
core_datasec (abfd)->size = core->c_dsize;
|
||||
core_regsec (abfd)->size = core->c_regs_size;
|
||||
core_reg2sec (abfd)->size = core->fp_stuff_size;
|
||||
|
||||
core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
|
||||
core_datasec (abfd)->vma = core->c_data_addr;
|
||||
core_regsec (abfd)->vma = 0;
|
||||
core_reg2sec (abfd)->vma = 0;
|
||||
|
||||
core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
|
||||
core_datasec (abfd)->filepos = core->c_len;
|
||||
/* We'll access the regs afresh in the core file, like any section: */
|
||||
core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos;
|
||||
core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos;
|
||||
|
||||
/* Align to word at least */
|
||||
core_stacksec (abfd)->alignment_power = 2;
|
||||
core_datasec (abfd)->alignment_power = 2;
|
||||
core_regsec (abfd)->alignment_power = 2;
|
||||
core_reg2sec (abfd)->alignment_power = 2;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
sunos4_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->hdr->c_cmdname;
|
||||
}
|
||||
|
||||
static int
|
||||
sunos4_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->hdr->c_signo;
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
if (core_bfd->xvec != exec_bfd->xvec)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Solaris core files do not include an aouthdr. */
|
||||
if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
|
||||
return TRUE;
|
||||
|
||||
return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
|
||||
(char *) exec_hdr (exec_bfd),
|
||||
sizeof (struct internal_exec)) == 0);
|
||||
}
|
||||
|
||||
#define MY_set_sizes sunos4_set_sizes
|
||||
static bfd_boolean
|
||||
sunos4_set_sizes (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
default:
|
||||
return FALSE;
|
||||
case bfd_arch_sparc:
|
||||
adata (abfd).page_size = 0x2000;
|
||||
adata (abfd).segment_size = 0x2000;
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
return TRUE;
|
||||
case bfd_arch_m68k:
|
||||
adata (abfd).page_size = 0x2000;
|
||||
adata (abfd).segment_size = 0x20000;
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* We default to setting the toolversion field to 1, as is required by
|
||||
SunOS. */
|
||||
#ifndef MY_exec_hdr_flags
|
||||
#define MY_exec_hdr_flags 1
|
||||
#endif
|
||||
|
||||
#ifndef MY_entry_is_text_address
|
||||
#define MY_entry_is_text_address 0
|
||||
#endif
|
||||
#ifndef MY_add_dynamic_symbols
|
||||
#define MY_add_dynamic_symbols 0
|
||||
#endif
|
||||
#ifndef MY_add_one_symbol
|
||||
#define MY_add_one_symbol 0
|
||||
#endif
|
||||
#ifndef MY_link_dynamic_object
|
||||
#define MY_link_dynamic_object 0
|
||||
#endif
|
||||
#ifndef MY_write_dynamic_symbol
|
||||
#define MY_write_dynamic_symbol 0
|
||||
#endif
|
||||
#ifndef MY_check_dynamic_reloc
|
||||
#define MY_check_dynamic_reloc 0
|
||||
#endif
|
||||
#ifndef MY_finish_dynamic_link
|
||||
#define MY_finish_dynamic_link 0
|
||||
#endif
|
||||
|
||||
static const struct aout_backend_data sunos4_aout_backend =
|
||||
{
|
||||
0, /* zmagic files are not contiguous */
|
||||
1, /* text includes header */
|
||||
MY_entry_is_text_address,
|
||||
MY_exec_hdr_flags,
|
||||
0, /* default text vma */
|
||||
sunos4_set_sizes,
|
||||
0, /* header is counted in zmagic text */
|
||||
MY_add_dynamic_symbols,
|
||||
MY_add_one_symbol,
|
||||
MY_link_dynamic_object,
|
||||
MY_write_dynamic_symbol,
|
||||
MY_check_dynamic_reloc,
|
||||
MY_finish_dynamic_link
|
||||
};
|
||||
|
||||
#define MY_core_file_failing_command sunos4_core_file_failing_command
|
||||
#define MY_core_file_failing_signal sunos4_core_file_failing_signal
|
||||
#define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
|
||||
|
||||
#define MY_bfd_debug_info_start bfd_void
|
||||
#define MY_bfd_debug_info_end bfd_void
|
||||
#define MY_bfd_debug_info_accumulate \
|
||||
(void (*) PARAMS ((bfd *, struct bfd_section *))) bfd_void
|
||||
#define MY_core_file_p sunos4_core_file_p
|
||||
#define MY_write_object_contents NAME(aout,sunos4_write_object_contents)
|
||||
#define MY_backend_data &sunos4_aout_backend
|
||||
|
||||
#ifndef TARGET_IS_LITTLE_ENDIAN_P
|
||||
#define TARGET_IS_BIG_ENDIAN_P
|
||||
#endif
|
||||
|
||||
#include "aout-target.h"
|
||||
5824
bfd/aoutx.h
5824
bfd/aoutx.h
File diff suppressed because it is too large
Load Diff
2165
bfd/archive.c
2165
bfd/archive.c
File diff suppressed because it is too large
Load Diff
243
bfd/archive64.c
243
bfd/archive64.c
@@ -1,243 +0,0 @@
|
||||
/* MIPS-specific support for 64-bit ELF
|
||||
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file supports the 64-bit (MIPS) ELF archives. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "aout/ar.h"
|
||||
|
||||
/* Irix 6 defines a 64bit archive map format, so that they can
|
||||
have archives more than 4 GB in size. */
|
||||
|
||||
bfd_boolean bfd_elf64_archive_slurp_armap (bfd *);
|
||||
bfd_boolean bfd_elf64_archive_write_armap
|
||||
(bfd *, unsigned int, struct orl *, unsigned int, int);
|
||||
|
||||
/* Read an Irix 6 armap. */
|
||||
|
||||
bfd_boolean
|
||||
bfd_elf64_archive_slurp_armap (bfd *abfd)
|
||||
{
|
||||
struct artdata *ardata = bfd_ardata (abfd);
|
||||
char nextname[17];
|
||||
file_ptr arhdrpos;
|
||||
bfd_size_type i, parsed_size, nsymz, stringsize, carsym_size, ptrsize;
|
||||
struct areltdata *mapdata;
|
||||
bfd_byte int_buf[8];
|
||||
char *stringbase;
|
||||
bfd_byte *raw_armap = NULL;
|
||||
carsym *carsyms;
|
||||
bfd_size_type amt;
|
||||
|
||||
ardata->symdefs = NULL;
|
||||
|
||||
/* Get the name of the first element. */
|
||||
arhdrpos = bfd_tell (abfd);
|
||||
i = bfd_bread (nextname, 16, abfd);
|
||||
if (i == 0)
|
||||
return TRUE;
|
||||
if (i != 16)
|
||||
return FALSE;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
|
||||
return FALSE;
|
||||
|
||||
/* Archives with traditional armaps are still permitted. */
|
||||
if (strncmp (nextname, "/ ", 16) == 0)
|
||||
return bfd_slurp_armap (abfd);
|
||||
|
||||
if (strncmp (nextname, "/SYM64/ ", 16) != 0)
|
||||
{
|
||||
bfd_has_map (abfd) = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
|
||||
if (mapdata == NULL)
|
||||
return FALSE;
|
||||
parsed_size = mapdata->parsed_size;
|
||||
bfd_release (abfd, mapdata);
|
||||
|
||||
if (bfd_bread (int_buf, 8, abfd) != 8)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nsymz = bfd_getb64 (int_buf);
|
||||
stringsize = parsed_size - 8 * nsymz - 8;
|
||||
|
||||
carsym_size = nsymz * sizeof (carsym);
|
||||
ptrsize = 8 * nsymz;
|
||||
|
||||
amt = carsym_size + stringsize + 1;
|
||||
ardata->symdefs = bfd_zalloc (abfd, amt);
|
||||
if (ardata->symdefs == NULL)
|
||||
return FALSE;
|
||||
carsyms = ardata->symdefs;
|
||||
stringbase = ((char *) ardata->symdefs) + carsym_size;
|
||||
|
||||
raw_armap = bfd_alloc (abfd, ptrsize);
|
||||
if (raw_armap == NULL)
|
||||
goto release_symdefs;
|
||||
|
||||
if (bfd_bread (raw_armap, ptrsize, abfd) != ptrsize
|
||||
|| bfd_bread (stringbase, stringsize, abfd) != stringsize)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
goto release_raw_armap;
|
||||
}
|
||||
|
||||
for (i = 0; i < nsymz; i++)
|
||||
{
|
||||
carsyms->file_offset = bfd_getb64 (raw_armap + i * 8);
|
||||
carsyms->name = stringbase;
|
||||
stringbase += strlen (stringbase) + 1;
|
||||
++carsyms;
|
||||
}
|
||||
*stringbase = '\0';
|
||||
|
||||
ardata->symdef_count = nsymz;
|
||||
ardata->first_file_filepos = bfd_tell (abfd);
|
||||
/* Pad to an even boundary if you have to. */
|
||||
ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
|
||||
|
||||
bfd_has_map (abfd) = TRUE;
|
||||
bfd_release (abfd, raw_armap);
|
||||
|
||||
return TRUE;
|
||||
|
||||
release_raw_armap:
|
||||
bfd_release (abfd, raw_armap);
|
||||
release_symdefs:
|
||||
bfd_release (abfd, ardata->symdefs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Write out an Irix 6 armap. The Irix 6 tools are supposed to be
|
||||
able to handle ordinary ELF armaps, but at least on Irix 6.2 the
|
||||
linker crashes. */
|
||||
|
||||
bfd_boolean
|
||||
bfd_elf64_archive_write_armap (bfd *arch,
|
||||
unsigned int elength,
|
||||
struct orl *map,
|
||||
unsigned int symbol_count,
|
||||
int stridx)
|
||||
{
|
||||
unsigned int ranlibsize = (symbol_count * 8) + 8;
|
||||
unsigned int stringsize = stridx;
|
||||
unsigned int mapsize = stringsize + ranlibsize;
|
||||
file_ptr archive_member_file_ptr;
|
||||
bfd *current = arch->archive_head;
|
||||
unsigned int count;
|
||||
struct ar_hdr hdr;
|
||||
unsigned int i;
|
||||
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, 0, sizeof (struct ar_hdr));
|
||||
strcpy (hdr.ar_name, "/SYM64/");
|
||||
sprintf (hdr.ar_size, "%-10d", (int) mapsize);
|
||||
sprintf (hdr.ar_date, "%ld", (long) time (NULL));
|
||||
/* This, at least, is what Intel coff sets the values to.: */
|
||||
sprintf ((hdr.ar_uid), "%d", 0);
|
||||
sprintf ((hdr.ar_gid), "%d", 0);
|
||||
sprintf ((hdr.ar_mode), "%-7o", (unsigned) 0);
|
||||
strncpy (hdr.ar_fmag, ARFMAG, 2);
|
||||
|
||||
for (i = 0; i < sizeof (struct ar_hdr); i++)
|
||||
if (((char *) (&hdr))[i] == '\0')
|
||||
(((char *) (&hdr))[i]) = ' ';
|
||||
|
||||
/* Write the ar header for this item and the number of symbols */
|
||||
|
||||
if (bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch)
|
||||
!= sizeof (struct ar_hdr))
|
||||
return FALSE;
|
||||
|
||||
bfd_putb64 ((bfd_vma) symbol_count, buf);
|
||||
if (bfd_bwrite (buf, 8, arch) != 8)
|
||||
return FALSE;
|
||||
|
||||
/* Two passes, first write the file offsets for each symbol -
|
||||
remembering that each offset is on a two byte boundary. */
|
||||
|
||||
/* Write out the file offset for the file associated with each
|
||||
symbol, and remember to keep the offsets padded out. */
|
||||
|
||||
current = arch->archive_head;
|
||||
count = 0;
|
||||
while (current != NULL && count < symbol_count)
|
||||
{
|
||||
/* For each symbol which is used defined in this object, write out
|
||||
the object file's address in the archive */
|
||||
|
||||
while (map[count].u.abfd == current)
|
||||
{
|
||||
bfd_putb64 ((bfd_vma) archive_member_file_ptr, buf);
|
||||
if (bfd_bwrite (buf, 8, arch) != 8)
|
||||
return FALSE;
|
||||
count++;
|
||||
}
|
||||
/* Add size of this archive entry */
|
||||
archive_member_file_ptr += (arelt_size (current)
|
||||
+ sizeof (struct ar_hdr));
|
||||
/* remember about the even alignment */
|
||||
archive_member_file_ptr += archive_member_file_ptr % 2;
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
/* now write the strings themselves */
|
||||
for (count = 0; count < symbol_count; count++)
|
||||
{
|
||||
size_t len = strlen (*map[count].name) + 1;
|
||||
|
||||
if (bfd_bwrite (*map[count].name, len, arch) != len)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* The spec says that this should be padded to an 8 byte boundary.
|
||||
However, the Irix 6.2 tools do not appear to do this. */
|
||||
while (padding != 0)
|
||||
{
|
||||
if (bfd_bwrite ("", 1, arch) != 1)
|
||||
return FALSE;
|
||||
--padding;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
1165
bfd/archures.c
1165
bfd/archures.c
File diff suppressed because it is too large
Load Diff
@@ -1,53 +0,0 @@
|
||||
/* BFD back-end for NetBSD/ARM a.out-ish binaries.
|
||||
Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define BYTES_IN_WORD 4
|
||||
#undef TARGET_IS_BIG_ENDIAN_P
|
||||
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
|
||||
#define DEFAULT_ARCH bfd_arch_arm
|
||||
#define DEFAULT_MID M_ARM6_NETBSD
|
||||
/*#define MACHTYPE_OK(mtype) ((mtype) == M_ARM6_NETBSD)*/
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MY(OP) CONCAT2 (armnetbsd_, OP)
|
||||
|
||||
/* This needs to start with a.out so GDB knows it is an a.out variant. */
|
||||
#define TARGETNAME "a.out-arm-netbsd"
|
||||
|
||||
#if 0
|
||||
#define NAME(x,y) CONCAT3 (aoutarm,_32_,y)
|
||||
|
||||
#define aoutarm_32_get_section_contents aout_32_get_section_contents
|
||||
|
||||
#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
|
||||
|
||||
#include "bfd.h" /* To ensure following declaration is OK */
|
||||
|
||||
const struct reloc_howto_struct *
|
||||
MY_bfd_reloc_type_lookup
|
||||
PARAMS ((bfd * abfd AND
|
||||
bfd_reloc_code_real_type code));
|
||||
#endif
|
||||
|
||||
#include "netbsd.h"
|
||||
875
bfd/bfd-in.h
875
bfd/bfd-in.h
@@ -1,875 +0,0 @@
|
||||
/* Main header file for the bfd library -- portable access to object files.
|
||||
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2001, 2002, 2003, 2004 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef __BFD_H_SEEN__
|
||||
#define __BFD_H_SEEN__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "symcat.h"
|
||||
#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
|
||||
#ifndef SABER
|
||||
/* This hack is to avoid a problem with some strict ANSI C preprocessors.
|
||||
The problem is, "32_" is not a valid preprocessing token, and we don't
|
||||
want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will
|
||||
cause the inner CONCAT2 macros to be evaluated first, producing
|
||||
still-valid pp-tokens. Then the final concatenation can be done. */
|
||||
#undef CONCAT4
|
||||
#define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* 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_LONG_LONG @BFD_HOST_LONG_LONG@
|
||||
#if @BFD_HOST_64_BIT_DEFINED@
|
||||
#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
|
||||
#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
|
||||
typedef BFD_HOST_64_BIT bfd_int64_t;
|
||||
typedef BFD_HOST_U_64_BIT bfd_uint64_t;
|
||||
#endif
|
||||
|
||||
#if BFD_ARCH_SIZE >= 64
|
||||
#define BFD64
|
||||
#endif
|
||||
|
||||
#ifndef INLINE
|
||||
#if __GNUC__ >= 2
|
||||
#define INLINE __inline__
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
|
||||
#if 0
|
||||
/* Poison. */
|
||||
#undef false
|
||||
#undef true
|
||||
#define false dont_use_false_in_bfd
|
||||
#define true dont_use_true_in_bfd
|
||||
#endif
|
||||
|
||||
#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;
|
||||
|
||||
#ifndef fprintf_vma
|
||||
#if BFD_HOST_64BIT_LONG
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
|
||||
#else
|
||||
#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
|
||||
#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
|
||||
#define fprintf_vma(s,x) \
|
||||
fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
|
||||
#define sprintf_vma(s,x) \
|
||||
sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else /* not BFD64 */
|
||||
|
||||
/* Represent a target address. Also used as a generic unsigned type
|
||||
which is guaranteed to be big enough to hold any arithmetic types
|
||||
we need to deal with. */
|
||||
typedef unsigned long bfd_vma;
|
||||
|
||||
/* A generic signed type which is guaranteed to be big enough to hold any
|
||||
arithmetic types we need to deal with. Can be assumed to be compatible
|
||||
with bfd_vma in the same way that signed and unsigned ints are compatible
|
||||
(as parameters, in assignment, etc). */
|
||||
typedef long bfd_signed_vma;
|
||||
|
||||
typedef unsigned long symvalue;
|
||||
typedef unsigned long bfd_size_type;
|
||||
|
||||
/* Print a bfd_vma x on stream s. */
|
||||
#define fprintf_vma(s,x) fprintf (s, "%08lx", x)
|
||||
#define sprintf_vma(s,x) sprintf (s, "%08lx", x)
|
||||
|
||||
#endif /* not BFD64 */
|
||||
|
||||
#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;
|
||||
|
||||
/* Values that may appear in the flags field of a BFD. These also
|
||||
appear in the object_flags field of the bfd_target structure, where
|
||||
they indicate the set of flags used by that backend (not all flags
|
||||
are meaningful for all object file formats) (FIXME: at the moment,
|
||||
the object_flags values have mostly just been copied from backend
|
||||
to another, and are not necessarily correct). */
|
||||
|
||||
/* No flags. */
|
||||
#define BFD_NO_FLAGS 0x00
|
||||
|
||||
/* BFD contains relocation entries. */
|
||||
#define HAS_RELOC 0x01
|
||||
|
||||
/* BFD is directly executable. */
|
||||
#define EXEC_P 0x02
|
||||
|
||||
/* BFD has line number information (basically used for F_LNNO in a
|
||||
COFF header). */
|
||||
#define HAS_LINENO 0x04
|
||||
|
||||
/* BFD has debugging information. */
|
||||
#define HAS_DEBUG 0x08
|
||||
|
||||
/* BFD has symbols. */
|
||||
#define HAS_SYMS 0x10
|
||||
|
||||
/* BFD has local symbols (basically used for F_LSYMS in a COFF
|
||||
header). */
|
||||
#define HAS_LOCALS 0x20
|
||||
|
||||
/* BFD is a dynamic object. */
|
||||
#define DYNAMIC 0x40
|
||||
|
||||
/* Text section is write protected (if D_PAGED is not set, this is
|
||||
like an a.out NMAGIC file) (the linker sets this by default, but
|
||||
clears it for -r or -N). */
|
||||
#define WP_TEXT 0x80
|
||||
|
||||
/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
|
||||
linker sets this by default, but clears it for -r or -n or -N). */
|
||||
#define D_PAGED 0x100
|
||||
|
||||
/* BFD is relaxable (this means that bfd_relax_section may be able to
|
||||
do something) (sometimes bfd_relax_section can do something even if
|
||||
this is not set). */
|
||||
#define BFD_IS_RELAXABLE 0x200
|
||||
|
||||
/* This may be set before writing out a BFD to request using a
|
||||
traditional format. For example, this is used to request that when
|
||||
writing out an a.out object the symbols not be hashed to eliminate
|
||||
duplicates. */
|
||||
#define BFD_TRADITIONAL_FORMAT 0x400
|
||||
|
||||
/* This flag indicates that the BFD contents are actually cached in
|
||||
memory. If this is set, iostream points to a bfd_in_memory struct. */
|
||||
#define BFD_IN_MEMORY 0x800
|
||||
|
||||
/* The sections in this BFD specify a memory page. */
|
||||
#define HAS_LOAD_PAGE 0x1000
|
||||
|
||||
/* Symbols and relocation. */
|
||||
|
||||
/* A count of carsyms (canonical archive symbols). */
|
||||
typedef unsigned long symindex;
|
||||
|
||||
/* How to perform a relocation. */
|
||||
typedef const struct reloc_howto_struct reloc_howto_type;
|
||||
|
||||
#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
|
||||
|
||||
/* General purpose part of a symbol X;
|
||||
target specific parts are in libcoff.h, libaout.h, etc. */
|
||||
|
||||
#define bfd_get_section(x) ((x)->section)
|
||||
#define bfd_get_output_section(x) ((x)->section->output_section)
|
||||
#define bfd_set_section(x,y) ((x)->section) = (y)
|
||||
#define bfd_asymbol_base(x) ((x)->section->vma)
|
||||
#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
|
||||
#define bfd_asymbol_name(x) ((x)->name)
|
||||
/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
|
||||
#define bfd_asymbol_bfd(x) ((x)->the_bfd)
|
||||
#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
|
||||
|
||||
/* A canonical archive symbol. */
|
||||
/* This is a type pun with struct ranlib on purpose! */
|
||||
typedef struct carsym
|
||||
{
|
||||
char *name;
|
||||
file_ptr file_offset; /* Look here to find the file. */
|
||||
}
|
||||
carsym; /* To make these you call a carsymogen. */
|
||||
|
||||
/* Used in generating armaps (archive tables of contents).
|
||||
Perhaps just a forward definition would do? */
|
||||
struct orl /* Output ranlib. */
|
||||
{
|
||||
char **name; /* Symbol name. */
|
||||
union
|
||||
{
|
||||
file_ptr pos;
|
||||
bfd *abfd;
|
||||
} u; /* bfd* or file position. */
|
||||
int namidx; /* Index into string table. */
|
||||
};
|
||||
|
||||
/* Linenumber stuff. */
|
||||
typedef struct lineno_cache_entry
|
||||
{
|
||||
unsigned int line_number; /* Linenumber from start of function. */
|
||||
union
|
||||
{
|
||||
struct bfd_symbol *sym; /* Function name. */
|
||||
bfd_vma offset; /* Offset into section. */
|
||||
} u;
|
||||
}
|
||||
alent;
|
||||
|
||||
/* Object and core file sections. */
|
||||
|
||||
#define align_power(addr, align) \
|
||||
(((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
|
||||
|
||||
typedef struct bfd_section *sec_ptr;
|
||||
|
||||
#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
|
||||
#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
|
||||
#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
|
||||
#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
|
||||
#define bfd_section_name(bfd, ptr) ((ptr)->name)
|
||||
#define bfd_section_size(bfd, ptr) ((ptr)->size)
|
||||
#define bfd_get_section_size(ptr) ((ptr)->size)
|
||||
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
|
||||
#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
|
||||
#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
|
||||
#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
|
||||
#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
|
||||
|
||||
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
|
||||
|
||||
#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
|
||||
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
|
||||
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
|
||||
/* Find the address one past the end of SEC. */
|
||||
#define bfd_get_section_limit(bfd, sec) \
|
||||
(((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
|
||||
/ bfd_octets_per_byte (bfd))
|
||||
|
||||
typedef struct stat stat_type;
|
||||
|
||||
typedef enum bfd_print_symbol
|
||||
{
|
||||
bfd_print_symbol_name,
|
||||
bfd_print_symbol_more,
|
||||
bfd_print_symbol_all
|
||||
} bfd_print_symbol_type;
|
||||
|
||||
/* Information about a symbol that nm needs. */
|
||||
|
||||
typedef struct _symbol_info
|
||||
{
|
||||
symvalue value;
|
||||
char type;
|
||||
const char *name; /* Symbol name. */
|
||||
unsigned char stab_type; /* Stab type. */
|
||||
char stab_other; /* Stab other. */
|
||||
short stab_desc; /* Stab desc. */
|
||||
const char *stab_name; /* String for stab type. */
|
||||
} symbol_info;
|
||||
|
||||
/* Get the name of a stabs type code. */
|
||||
|
||||
extern const char *bfd_get_stab_name (int);
|
||||
|
||||
/* Hash table routines. There is no way to free up a hash table. */
|
||||
|
||||
/* An element in the hash table. Most uses will actually use a larger
|
||||
structure, and an instance of this will be the first field. */
|
||||
|
||||
struct bfd_hash_entry
|
||||
{
|
||||
/* Next entry for this hash code. */
|
||||
struct bfd_hash_entry *next;
|
||||
/* String being hashed. */
|
||||
const char *string;
|
||||
/* Hash code. This is the full hash code, not the index into the
|
||||
table. */
|
||||
unsigned long hash;
|
||||
};
|
||||
|
||||
/* A hash table. */
|
||||
|
||||
struct bfd_hash_table
|
||||
{
|
||||
/* The hash array. */
|
||||
struct bfd_hash_entry **table;
|
||||
/* The number of slots in the hash table. */
|
||||
unsigned int size;
|
||||
/* A function used to create new elements in the hash table. The
|
||||
first entry is itself a pointer to an element. When this
|
||||
function is first invoked, this pointer will be NULL. However,
|
||||
having the pointer permits a hierarchy of method functions to be
|
||||
built each of which calls the function in the superclass. Thus
|
||||
each function should be written to allocate a new block of memory
|
||||
only if the argument is NULL. */
|
||||
struct bfd_hash_entry *(*newfunc)
|
||||
(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;
|
||||
};
|
||||
|
||||
/* 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 *));
|
||||
|
||||
/* 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 size);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Replace an entry in a hash table. */
|
||||
extern void bfd_hash_replace
|
||||
(struct bfd_hash_table *, struct bfd_hash_entry *old,
|
||||
struct bfd_hash_entry *nw);
|
||||
|
||||
/* Base method for creating a hash table entry. */
|
||||
extern struct bfd_hash_entry *bfd_hash_newfunc
|
||||
(struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
|
||||
|
||||
/* Grab some space for a hash table entry. */
|
||||
extern void *bfd_hash_allocate
|
||||
(struct bfd_hash_table *, unsigned int);
|
||||
|
||||
/* Traverse a hash table in a random order, calling a function on each
|
||||
element. If the function returns FALSE, the traversal stops. The
|
||||
INFO argument is passed to the function. */
|
||||
extern void bfd_hash_traverse
|
||||
(struct bfd_hash_table *,
|
||||
bfd_boolean (*) (struct bfd_hash_entry *, void *),
|
||||
void *info);
|
||||
|
||||
/* Allows the default size of a hash table to be configured. New hash
|
||||
tables allocated using bfd_hash_table_init will be created with
|
||||
this size. */
|
||||
extern void bfd_hash_set_default_size (bfd_size_type);
|
||||
|
||||
/* This structure is used to keep track of stabs in sections
|
||||
information while linking. */
|
||||
|
||||
struct stab_info
|
||||
{
|
||||
/* A hash table used to hold stabs strings. */
|
||||
struct bfd_strtab_hash *strings;
|
||||
/* The header file hash table. */
|
||||
struct bfd_hash_table includes;
|
||||
/* The first .stabstr section. */
|
||||
struct bfd_section *stabstr;
|
||||
};
|
||||
|
||||
#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
|
||||
|
||||
/* User program access to BFD facilities. */
|
||||
|
||||
/* Direct I/O routines, for programs which know more about the object
|
||||
file than BFD does. Use higher level routines if possible. */
|
||||
|
||||
extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
|
||||
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
|
||||
extern int bfd_seek (bfd *, file_ptr, int);
|
||||
extern file_ptr bfd_tell (bfd *);
|
||||
extern int bfd_flush (bfd *);
|
||||
extern int bfd_stat (bfd *, struct stat *);
|
||||
|
||||
/* Deprecated old routines. */
|
||||
#if __GNUC__
|
||||
#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
|
||||
(warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
|
||||
bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
|
||||
#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
|
||||
(warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
|
||||
bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
|
||||
#else
|
||||
#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
|
||||
(warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
|
||||
bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
|
||||
#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
|
||||
(warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
|
||||
bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
|
||||
#endif
|
||||
extern void warn_deprecated (const char *, const char *, int, const char *);
|
||||
|
||||
/* Cast from const char * to char * so that caller can assign to
|
||||
a char * without a warning. */
|
||||
#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
|
||||
#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
|
||||
#define bfd_get_format(abfd) ((abfd)->format)
|
||||
#define bfd_get_target(abfd) ((abfd)->xvec->name)
|
||||
#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
|
||||
#define bfd_family_coff(abfd) \
|
||||
(bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
|
||||
bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
|
||||
#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
|
||||
#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
|
||||
#define bfd_header_big_endian(abfd) \
|
||||
((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
|
||||
#define bfd_header_little_endian(abfd) \
|
||||
((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
|
||||
#define bfd_get_file_flags(abfd) ((abfd)->flags)
|
||||
#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
|
||||
#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
|
||||
#define bfd_my_archive(abfd) ((abfd)->my_archive)
|
||||
#define bfd_has_map(abfd) ((abfd)->has_armap)
|
||||
|
||||
#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
|
||||
#define bfd_usrdata(abfd) ((abfd)->usrdata)
|
||||
|
||||
#define bfd_get_start_address(abfd) ((abfd)->start_address)
|
||||
#define bfd_get_symcount(abfd) ((abfd)->symcount)
|
||||
#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
|
||||
#define bfd_count_sections(abfd) ((abfd)->section_count)
|
||||
|
||||
#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
|
||||
|
||||
#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
|
||||
|
||||
#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
|
||||
|
||||
extern bfd_boolean bfd_cache_close
|
||||
(bfd *abfd);
|
||||
/* NB: This declaration should match the autogenerated one in libbfd.h. */
|
||||
|
||||
extern bfd_boolean bfd_cache_close_all (void);
|
||||
|
||||
extern bfd_boolean bfd_record_phdr
|
||||
(bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
|
||||
bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
|
||||
|
||||
/* Byte swapping routines. */
|
||||
|
||||
bfd_uint64_t bfd_getb64 (const void *);
|
||||
bfd_uint64_t bfd_getl64 (const void *);
|
||||
bfd_int64_t bfd_getb_signed_64 (const void *);
|
||||
bfd_int64_t bfd_getl_signed_64 (const void *);
|
||||
bfd_vma bfd_getb32 (const void *);
|
||||
bfd_vma bfd_getl32 (const void *);
|
||||
bfd_signed_vma bfd_getb_signed_32 (const void *);
|
||||
bfd_signed_vma bfd_getl_signed_32 (const void *);
|
||||
bfd_vma bfd_getb16 (const void *);
|
||||
bfd_vma bfd_getl16 (const void *);
|
||||
bfd_signed_vma bfd_getb_signed_16 (const void *);
|
||||
bfd_signed_vma bfd_getl_signed_16 (const void *);
|
||||
void bfd_putb64 (bfd_uint64_t, void *);
|
||||
void bfd_putl64 (bfd_uint64_t, void *);
|
||||
void bfd_putb32 (bfd_vma, void *);
|
||||
void bfd_putl32 (bfd_vma, void *);
|
||||
void bfd_putb16 (bfd_vma, void *);
|
||||
void bfd_putl16 (bfd_vma, void *);
|
||||
|
||||
/* Byte swapping routines which take size and endiannes as arguments. */
|
||||
|
||||
bfd_uint64_t bfd_get_bits (const void *, int, bfd_boolean);
|
||||
void bfd_put_bits (bfd_uint64_t, void *, int, bfd_boolean);
|
||||
|
||||
extern bfd_boolean bfd_section_already_linked_table_init (void);
|
||||
extern void bfd_section_already_linked_table_free (void);
|
||||
|
||||
/* Externally visible ECOFF routines. */
|
||||
|
||||
#if defined(__STDC__) || defined(ALMOST_STDC)
|
||||
struct ecoff_debug_info;
|
||||
struct ecoff_debug_swap;
|
||||
struct ecoff_extr;
|
||||
struct bfd_symbol;
|
||||
struct bfd_link_info;
|
||||
struct bfd_link_hash_entry;
|
||||
struct bfd_elf_version_tree;
|
||||
#endif
|
||||
extern bfd_vma bfd_ecoff_get_gp_value
|
||||
(bfd * abfd);
|
||||
extern bfd_boolean bfd_ecoff_set_gp_value
|
||||
(bfd *abfd, bfd_vma gp_value);
|
||||
extern bfd_boolean bfd_ecoff_set_regmasks
|
||||
(bfd *abfd, unsigned long gprmask, unsigned long fprmask,
|
||||
unsigned long *cprmask);
|
||||
extern void *bfd_ecoff_debug_init
|
||||
(bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
|
||||
extern void bfd_ecoff_debug_free
|
||||
(void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_ecoff_debug_accumulate
|
||||
(void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
|
||||
struct ecoff_debug_info *input_debug,
|
||||
const struct ecoff_debug_swap *input_swap, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_ecoff_debug_accumulate_other
|
||||
(void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
|
||||
struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_ecoff_debug_externals
|
||||
(bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap, bfd_boolean relocatable,
|
||||
bfd_boolean (*get_extr) (struct bfd_symbol *, struct ecoff_extr *),
|
||||
void (*set_index) (struct bfd_symbol *, bfd_size_type));
|
||||
extern bfd_boolean bfd_ecoff_debug_one_external
|
||||
(bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap, const char *name,
|
||||
struct ecoff_extr *esym);
|
||||
extern bfd_size_type bfd_ecoff_debug_size
|
||||
(bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap);
|
||||
extern bfd_boolean bfd_ecoff_write_debug
|
||||
(bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap, file_ptr where);
|
||||
extern bfd_boolean bfd_ecoff_write_accumulated_debug
|
||||
(void *handle, bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap,
|
||||
struct bfd_link_info *info, file_ptr where);
|
||||
|
||||
/* Externally visible ELF routines. */
|
||||
|
||||
struct bfd_link_needed_list
|
||||
{
|
||||
struct bfd_link_needed_list *next;
|
||||
bfd *by;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
enum dynamic_lib_link_class {
|
||||
DYN_NORMAL = 0,
|
||||
DYN_AS_NEEDED = 1,
|
||||
DYN_DT_NEEDED = 2,
|
||||
DYN_NO_ADD_NEEDED = 4,
|
||||
DYN_NO_NEEDED = 8
|
||||
};
|
||||
|
||||
extern bfd_boolean bfd_elf_record_link_assignment
|
||||
(bfd *, struct bfd_link_info *, const char *, bfd_boolean);
|
||||
extern struct bfd_link_needed_list *bfd_elf_get_needed_list
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_elf_get_bfd_needed_list
|
||||
(bfd *, struct bfd_link_needed_list **);
|
||||
extern bfd_boolean bfd_elf_size_dynamic_sections
|
||||
(bfd *, const char *, const char *, const char *, const char * const *,
|
||||
struct bfd_link_info *, struct bfd_section **, struct bfd_elf_version_tree *);
|
||||
extern void bfd_elf_set_dt_needed_name
|
||||
(bfd *, const char *);
|
||||
extern const char *bfd_elf_get_dt_soname
|
||||
(bfd *);
|
||||
extern void bfd_elf_set_dyn_lib_class
|
||||
(bfd *, int);
|
||||
extern int bfd_elf_get_dyn_lib_class
|
||||
(bfd *);
|
||||
extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_elf_discard_info
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* Return an upper bound on the number of bytes required to store a
|
||||
copy of ABFD's program header table entries. Return -1 if an error
|
||||
occurs; bfd_get_error will return an appropriate code. */
|
||||
extern long bfd_get_elf_phdr_upper_bound
|
||||
(bfd *abfd);
|
||||
|
||||
/* Copy ABFD's program header table entries to *PHDRS. The entries
|
||||
will be stored as an array of Elf_Internal_Phdr structures, as
|
||||
defined in include/elf/internal.h. To find out how large the
|
||||
buffer needs to be, call bfd_get_elf_phdr_upper_bound.
|
||||
|
||||
Return the number of program header table entries read, or -1 if an
|
||||
error occurs; bfd_get_error will return an appropriate code. */
|
||||
extern int bfd_get_elf_phdrs
|
||||
(bfd *abfd, void *phdrs);
|
||||
|
||||
/* Create a new BFD as if by bfd_openr. Rather than opening a file,
|
||||
reconstruct an ELF file by reading the segments out of remote memory
|
||||
based on the ELF file header at EHDR_VMA and the ELF program headers it
|
||||
points to. If not null, *LOADBASEP is filled in with the difference
|
||||
between the VMAs from which the segments were read, and the VMAs the
|
||||
file headers (and hence BFD's idea of each section's VMA) put them at.
|
||||
|
||||
The function TARGET_READ_MEMORY is called to copy LEN bytes from the
|
||||
remote memory at target address VMA into the local buffer at MYADDR; it
|
||||
should return zero on success or an `errno' code on failure. TEMPL must
|
||||
be a BFD for an ELF target with the word size and byte order found in
|
||||
the remote memory. */
|
||||
extern bfd *bfd_elf_bfd_from_remote_memory
|
||||
(bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
|
||||
int (*target_read_memory) (bfd_vma vma, char *myaddr, int len));
|
||||
|
||||
/* Return the arch_size field of an elf bfd, or -1 if not elf. */
|
||||
extern int bfd_get_arch_size
|
||||
(bfd *);
|
||||
|
||||
/* Return TRUE if address "naturally" sign extends, or -1 if not elf. */
|
||||
extern int bfd_get_sign_extend_vma
|
||||
(bfd *);
|
||||
|
||||
extern struct bfd_section *_bfd_elf_tls_setup
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
|
||||
(bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
|
||||
|
||||
/* SunOS shared library support routines for the linker. */
|
||||
|
||||
extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_sunos_record_link_assignment
|
||||
(bfd *, struct bfd_link_info *, const char *);
|
||||
extern bfd_boolean bfd_sunos_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *, struct bfd_section **, struct bfd_section **, struct bfd_section **);
|
||||
|
||||
/* Linux shared library support routines for the linker. */
|
||||
|
||||
extern bfd_boolean bfd_i386linux_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_m68klinux_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_sparclinux_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* mmap hacks */
|
||||
|
||||
struct _bfd_window_internal;
|
||||
typedef struct _bfd_window_internal bfd_window_internal;
|
||||
|
||||
typedef struct _bfd_window
|
||||
{
|
||||
/* What the user asked for. */
|
||||
void *data;
|
||||
bfd_size_type size;
|
||||
/* The actual window used by BFD. Small user-requested read-only
|
||||
regions sharing a page may share a single window into the object
|
||||
file. Read-write versions shouldn't until I've fixed things to
|
||||
keep track of which portions have been claimed by the
|
||||
application; don't want to give the same region back when the
|
||||
application wants two writable copies! */
|
||||
struct _bfd_window_internal *i;
|
||||
}
|
||||
bfd_window;
|
||||
|
||||
extern void bfd_init_window
|
||||
(bfd_window *);
|
||||
extern void bfd_free_window
|
||||
(bfd_window *);
|
||||
extern bfd_boolean bfd_get_file_window
|
||||
(bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean);
|
||||
|
||||
/* XCOFF support routines for the linker. */
|
||||
|
||||
extern bfd_boolean bfd_xcoff_link_record_set
|
||||
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type);
|
||||
extern bfd_boolean bfd_xcoff_import_symbol
|
||||
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma,
|
||||
const char *, const char *, const char *, unsigned int);
|
||||
extern bfd_boolean bfd_xcoff_export_symbol
|
||||
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
|
||||
extern bfd_boolean bfd_xcoff_link_count_reloc
|
||||
(bfd *, struct bfd_link_info *, const char *);
|
||||
extern bfd_boolean bfd_xcoff_record_link_assignment
|
||||
(bfd *, struct bfd_link_info *, const char *);
|
||||
extern bfd_boolean bfd_xcoff_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *, const char *, const char *,
|
||||
unsigned long, unsigned long, unsigned long, bfd_boolean,
|
||||
int, bfd_boolean, bfd_boolean, struct bfd_section **, bfd_boolean);
|
||||
extern bfd_boolean bfd_xcoff_link_generate_rtinit
|
||||
(bfd *, const char *, const char *, bfd_boolean);
|
||||
|
||||
/* XCOFF support routines for ar. */
|
||||
extern bfd_boolean bfd_xcoff_ar_archive_set_magic
|
||||
(bfd *, char *);
|
||||
|
||||
/* Externally visible COFF routines. */
|
||||
|
||||
#if defined(__STDC__) || defined(ALMOST_STDC)
|
||||
struct internal_syment;
|
||||
union internal_auxent;
|
||||
#endif
|
||||
|
||||
extern bfd_boolean bfd_coff_get_syment
|
||||
(bfd *, struct bfd_symbol *, struct internal_syment *);
|
||||
|
||||
extern bfd_boolean bfd_coff_get_auxent
|
||||
(bfd *, struct bfd_symbol *, int, union internal_auxent *);
|
||||
|
||||
extern bfd_boolean bfd_coff_set_symbol_class
|
||||
(bfd *, struct bfd_symbol *, unsigned int);
|
||||
|
||||
extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
|
||||
(bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
|
||||
|
||||
/* ARM Interworking support. Called from linker. */
|
||||
extern bfd_boolean bfd_arm_allocate_interworking_sections
|
||||
(struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_arm_process_before_allocation
|
||||
(bfd *, struct bfd_link_info *, int);
|
||||
|
||||
extern bfd_boolean bfd_arm_get_bfd_for_interworking
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* PE ARM Interworking support. Called from linker. */
|
||||
extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
|
||||
(struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_arm_pe_process_before_allocation
|
||||
(bfd *, struct bfd_link_info *, int);
|
||||
|
||||
extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* ELF ARM Interworking support. Called from linker. */
|
||||
extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
|
||||
(struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_elf32_arm_process_before_allocation
|
||||
(bfd *, struct bfd_link_info *, int, int);
|
||||
|
||||
void bfd_elf32_arm_set_target_relocs
|
||||
(struct bfd_link_info *, int, char *);
|
||||
|
||||
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* ARM Note section processing. */
|
||||
extern bfd_boolean bfd_arm_merge_machines
|
||||
(bfd *, bfd *);
|
||||
|
||||
extern bfd_boolean bfd_arm_update_notes
|
||||
(bfd *, const char *);
|
||||
|
||||
extern unsigned int bfd_arm_get_mach_from_notes
|
||||
(bfd *, const char *);
|
||||
|
||||
/* TI COFF load page support. */
|
||||
extern void bfd_ticoff_set_section_load_page
|
||||
(struct bfd_section *, int);
|
||||
|
||||
extern int bfd_ticoff_get_section_load_page
|
||||
(struct bfd_section *);
|
||||
|
||||
/* H8/300 functions. */
|
||||
extern bfd_vma bfd_h8300_pad_address
|
||||
(bfd *, bfd_vma);
|
||||
|
||||
/* IA64 Itanium code generation. Called from linker. */
|
||||
extern void bfd_elf32_ia64_after_parse
|
||||
(int);
|
||||
|
||||
extern void bfd_elf64_ia64_after_parse
|
||||
(int);
|
||||
|
||||
/* This structure is used for a comdat section, as in PE. A comdat
|
||||
section is associated with a particular symbol. When the linker
|
||||
sees a comdat section, it keeps only one of the sections with a
|
||||
given name and associated with a given symbol. */
|
||||
|
||||
struct coff_comdat_info
|
||||
{
|
||||
/* The name of the symbol associated with a comdat section. */
|
||||
const char *name;
|
||||
|
||||
/* The local symbol table index of the symbol associated with a
|
||||
comdat section. This is only meaningful to the object file format
|
||||
specific code; it is not an index into the list returned by
|
||||
bfd_canonicalize_symtab. */
|
||||
long symbol;
|
||||
};
|
||||
|
||||
extern struct coff_comdat_info *bfd_coff_get_comdat_section
|
||||
(bfd *, struct bfd_section *);
|
||||
|
||||
4647
bfd/bfd-in2.h
4647
bfd/bfd-in2.h
File diff suppressed because it is too large
Load Diff
450
bfd/bfdio.c
450
bfd/bfdio.c
@@ -1,450 +0,0 @@
|
||||
/* Low-level I/O routines for BFDs.
|
||||
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR 0100 /* Execute by owner. */
|
||||
#endif
|
||||
#ifndef S_IXGRP
|
||||
#define S_IXGRP 0010 /* Execute by group. */
|
||||
#endif
|
||||
#ifndef S_IXOTH
|
||||
#define S_IXOTH 0001 /* Execute by others. */
|
||||
#endif
|
||||
|
||||
file_ptr
|
||||
real_ftell (FILE *file)
|
||||
{
|
||||
#if defined (HAVE_FTELLO64)
|
||||
return ftello64 (file);
|
||||
#elif defined (HAVE_FTELLO)
|
||||
return ftello (file);
|
||||
#else
|
||||
return ftell (file);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
real_fseek (FILE *file, file_ptr offset, int whence)
|
||||
{
|
||||
#if defined (HAVE_FSEEKO64)
|
||||
return fseeko64 (file, offset, whence);
|
||||
#elif defined (HAVE_FSEEKO)
|
||||
return fseeko (file, offset, whence);
|
||||
#else
|
||||
return fseek (file, offset, whence);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL_DEFINITION
|
||||
struct bfd_iovec
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
The <<struct bfd_iovec>> contains the internal file I/O class.
|
||||
Each <<BFD>> has an instance of this class and all file I/O is
|
||||
routed through it (it is assumed that the instance implements
|
||||
all methods listed below).
|
||||
|
||||
.struct bfd_iovec
|
||||
.{
|
||||
. {* To avoid problems with macros, a "b" rather than "f"
|
||||
. prefix is prepended to each method name. *}
|
||||
. {* Attempt to read/write NBYTES on ABFD's IOSTREAM storing/fetching
|
||||
. bytes starting at PTR. Return the number of bytes actually
|
||||
. transfered (a read past end-of-file returns less than NBYTES),
|
||||
. or -1 (setting <<bfd_error>>) if an error occurs. *}
|
||||
. file_ptr (*bread) (struct bfd *abfd, void *ptr, file_ptr nbytes);
|
||||
. file_ptr (*bwrite) (struct bfd *abfd, const void *ptr,
|
||||
. file_ptr nbytes);
|
||||
. {* Return the current IOSTREAM file offset, or -1 (setting <<bfd_error>>
|
||||
. if an error occurs. *}
|
||||
. file_ptr (*btell) (struct bfd *abfd);
|
||||
. {* For the following, on successful completion a value of 0 is returned.
|
||||
. Otherwise, a value of -1 is returned (and <<bfd_error>> is set). *}
|
||||
. int (*bseek) (struct bfd *abfd, file_ptr offset, int whence);
|
||||
. int (*bclose) (struct bfd *abfd);
|
||||
. int (*bflush) (struct bfd *abfd);
|
||||
. int (*bstat) (struct bfd *abfd, struct stat *sb);
|
||||
.};
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* Return value is amount read. */
|
||||
|
||||
bfd_size_type
|
||||
bfd_bread (void *ptr, bfd_size_type size, bfd *abfd)
|
||||
{
|
||||
size_t nread;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
{
|
||||
struct bfd_in_memory *bim;
|
||||
bfd_size_type get;
|
||||
|
||||
bim = abfd->iostream;
|
||||
get = size;
|
||||
if (abfd->where + get > bim->size)
|
||||
{
|
||||
if (bim->size < (bfd_size_type) abfd->where)
|
||||
get = 0;
|
||||
else
|
||||
get = bim->size - abfd->where;
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
}
|
||||
memcpy (ptr, bim->buffer + abfd->where, (size_t) get);
|
||||
abfd->where += get;
|
||||
return get;
|
||||
}
|
||||
|
||||
if (abfd->iovec)
|
||||
nread = abfd->iovec->bread (abfd, ptr, size);
|
||||
else
|
||||
nread = 0;
|
||||
if (nread != (size_t) -1)
|
||||
abfd->where += nread;
|
||||
|
||||
return nread;
|
||||
}
|
||||
|
||||
bfd_size_type
|
||||
bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd)
|
||||
{
|
||||
size_t nwrote;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
{
|
||||
struct bfd_in_memory *bim = abfd->iostream;
|
||||
|
||||
size = (size_t) size;
|
||||
if (abfd->where + size > bim->size)
|
||||
{
|
||||
bfd_size_type newsize, oldsize;
|
||||
|
||||
oldsize = (bim->size + 127) & ~(bfd_size_type) 127;
|
||||
bim->size = abfd->where + size;
|
||||
/* Round up to cut down on memory fragmentation */
|
||||
newsize = (bim->size + 127) & ~(bfd_size_type) 127;
|
||||
if (newsize > oldsize)
|
||||
{
|
||||
bim->buffer = bfd_realloc (bim->buffer, newsize);
|
||||
if (bim->buffer == 0)
|
||||
{
|
||||
bim->size = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
memcpy (bim->buffer + abfd->where, ptr, (size_t) size);
|
||||
abfd->where += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
if (abfd->iovec)
|
||||
nwrote = abfd->iovec->bwrite (abfd, ptr, size);
|
||||
else
|
||||
nwrote = 0;
|
||||
|
||||
if (nwrote != (size_t) -1)
|
||||
abfd->where += nwrote;
|
||||
if (nwrote != size)
|
||||
{
|
||||
#ifdef ENOSPC
|
||||
errno = ENOSPC;
|
||||
#endif
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
}
|
||||
return nwrote;
|
||||
}
|
||||
|
||||
file_ptr
|
||||
bfd_tell (bfd *abfd)
|
||||
{
|
||||
file_ptr ptr;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
return abfd->where;
|
||||
|
||||
if (abfd->iovec)
|
||||
{
|
||||
ptr = abfd->iovec->btell (abfd);
|
||||
|
||||
if (abfd->my_archive)
|
||||
ptr -= abfd->origin;
|
||||
}
|
||||
else
|
||||
ptr = 0;
|
||||
|
||||
abfd->where = ptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int
|
||||
bfd_flush (bfd *abfd)
|
||||
{
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
return 0;
|
||||
|
||||
if (abfd->iovec)
|
||||
return abfd->iovec->bflush (abfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns 0 for success, negative value for failure (in which case
|
||||
bfd_get_error can retrieve the error code). */
|
||||
int
|
||||
bfd_stat (bfd *abfd, struct stat *statbuf)
|
||||
{
|
||||
int result;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
abort ();
|
||||
|
||||
if (abfd->iovec)
|
||||
result = abfd->iovec->bstat (abfd, statbuf);
|
||||
else
|
||||
result = -1;
|
||||
|
||||
if (result < 0)
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Returns 0 for success, nonzero for failure (in which case bfd_get_error
|
||||
can retrieve the error code). */
|
||||
|
||||
int
|
||||
bfd_seek (bfd *abfd, file_ptr position, int direction)
|
||||
{
|
||||
int result;
|
||||
file_ptr file_position;
|
||||
/* For the time being, a BFD may not seek to it's end. The problem
|
||||
is that we don't easily have a way to recognize the end of an
|
||||
element in an archive. */
|
||||
|
||||
BFD_ASSERT (direction == SEEK_SET || direction == SEEK_CUR);
|
||||
|
||||
if (direction == SEEK_CUR && position == 0)
|
||||
return 0;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
{
|
||||
struct bfd_in_memory *bim;
|
||||
|
||||
bim = abfd->iostream;
|
||||
|
||||
if (direction == SEEK_SET)
|
||||
abfd->where = position;
|
||||
else
|
||||
abfd->where += position;
|
||||
|
||||
if (abfd->where > bim->size)
|
||||
{
|
||||
if ((abfd->direction == write_direction) ||
|
||||
(abfd->direction == both_direction))
|
||||
{
|
||||
bfd_size_type newsize, oldsize;
|
||||
|
||||
oldsize = (bim->size + 127) & ~(bfd_size_type) 127;
|
||||
bim->size = abfd->where;
|
||||
/* Round up to cut down on memory fragmentation */
|
||||
newsize = (bim->size + 127) & ~(bfd_size_type) 127;
|
||||
if (newsize > oldsize)
|
||||
{
|
||||
bim->buffer = bfd_realloc (bim->buffer, newsize);
|
||||
if (bim->buffer == 0)
|
||||
{
|
||||
bim->size = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
abfd->where = bim->size;
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (abfd->format != bfd_archive && abfd->my_archive == 0)
|
||||
{
|
||||
#if 0
|
||||
/* Explanation for this code: I'm only about 95+% sure that the above
|
||||
conditions are sufficient and that all i/o calls are properly
|
||||
adjusting the `where' field. So this is sort of an `assert'
|
||||
that the `where' field is correct. If we can go a while without
|
||||
tripping the abort, we can probably safely disable this code,
|
||||
so that the real optimizations happen. */
|
||||
file_ptr where_am_i_now;
|
||||
where_am_i_now = real_ftell (bfd_cache_lookup (abfd));
|
||||
if (abfd->my_archive)
|
||||
where_am_i_now -= abfd->origin;
|
||||
if (where_am_i_now != abfd->where)
|
||||
abort ();
|
||||
#endif
|
||||
if (direction == SEEK_SET && (bfd_vma) position == abfd->where)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We need something smarter to optimize access to archives.
|
||||
Currently, anything inside an archive is read via the file
|
||||
handle for the archive. Which means that a bfd_seek on one
|
||||
component affects the `current position' in the archive, as
|
||||
well as in any other component.
|
||||
|
||||
It might be sufficient to put a spike through the cache
|
||||
abstraction, and look to the archive for the file position,
|
||||
but I think we should try for something cleaner.
|
||||
|
||||
In the meantime, no optimization for archives. */
|
||||
}
|
||||
|
||||
file_position = position;
|
||||
if (direction == SEEK_SET && abfd->my_archive != NULL)
|
||||
file_position += abfd->origin;
|
||||
|
||||
if (abfd->iovec)
|
||||
result = abfd->iovec->bseek (abfd, file_position, direction);
|
||||
else
|
||||
result = -1;
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
int hold_errno = errno;
|
||||
|
||||
/* Force redetermination of `where' field. */
|
||||
bfd_tell (abfd);
|
||||
|
||||
/* An EINVAL error probably means that the file offset was
|
||||
absurd. */
|
||||
if (hold_errno == EINVAL)
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
else
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
errno = hold_errno;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Adjust `where' field. */
|
||||
if (direction == SEEK_SET)
|
||||
abfd->where = position;
|
||||
else
|
||||
abfd->where += position;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_mtime
|
||||
|
||||
SYNOPSIS
|
||||
long bfd_get_mtime (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the file modification time (as read from the file system, or
|
||||
from the archive header for archive members).
|
||||
|
||||
*/
|
||||
|
||||
long
|
||||
bfd_get_mtime (bfd *abfd)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if (abfd->mtime_set)
|
||||
return abfd->mtime;
|
||||
|
||||
if (abfd->iovec == NULL)
|
||||
return 0;
|
||||
|
||||
if (abfd->iovec->bstat (abfd, &buf) != 0)
|
||||
return 0;
|
||||
|
||||
abfd->mtime = buf.st_mtime; /* Save value in case anyone wants it */
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_size
|
||||
|
||||
SYNOPSIS
|
||||
long bfd_get_size (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the file size (as read from file system) for the file
|
||||
associated with BFD @var{abfd}.
|
||||
|
||||
The initial motivation for, and use of, this routine is not
|
||||
so we can get the exact size of the object the BFD applies to, since
|
||||
that might not be generally possible (archive members for example).
|
||||
It would be ideal if someone could eventually modify
|
||||
it so that such results were guaranteed.
|
||||
|
||||
Instead, we want to ask questions like "is this NNN byte sized
|
||||
object I'm about to try read from file offset YYY reasonable?"
|
||||
As as example of where we might do this, some object formats
|
||||
use string tables for which the first <<sizeof (long)>> bytes of the
|
||||
table contain the size of the table itself, including the size bytes.
|
||||
If an application tries to read what it thinks is one of these
|
||||
string tables, without some way to validate the size, and for
|
||||
some reason the size is wrong (byte swapping error, wrong location
|
||||
for the string table, etc.), the only clue is likely to be a read
|
||||
error when it tries to read the table, or a "virtual memory
|
||||
exhausted" error when it tries to allocate 15 bazillon bytes
|
||||
of space for the 15 bazillon byte table it is about to read.
|
||||
This function at least allows us to answer the question, "is the
|
||||
size reasonable?".
|
||||
*/
|
||||
|
||||
long
|
||||
bfd_get_size (bfd *abfd)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
return ((struct bfd_in_memory *) abfd->iostream)->size;
|
||||
|
||||
if (abfd->iovec == NULL)
|
||||
return 0;
|
||||
|
||||
if (abfd->iovec->bstat (abfd, &buf) != 0)
|
||||
return 0;
|
||||
|
||||
return buf.st_size;
|
||||
}
|
||||
251
bfd/bfdwin.c
251
bfd/bfdwin.c
@@ -1,251 +0,0 @@
|
||||
/* Support for memory-mapped windows into a BFD.
|
||||
Copyright 1995, 1996, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/* Currently, if USE_MMAP is undefined, none if the window stuff is
|
||||
used. Okay, so it's mis-named. At least the command-line option
|
||||
"--without-mmap" is more obvious than "--without-windows" or some
|
||||
such. */
|
||||
|
||||
#ifdef USE_MMAP
|
||||
|
||||
#undef HAVE_MPROTECT /* code's not tested yet */
|
||||
|
||||
#if HAVE_MMAP || HAVE_MPROTECT || HAVE_MADVISE
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
static int debug_windows;
|
||||
|
||||
/* The idea behind the next and refcount fields is that one mapped
|
||||
region can suffice for multiple read-only windows or multiple
|
||||
non-overlapping read-write windows. It's not implemented yet
|
||||
though. */
|
||||
|
||||
/*
|
||||
INTERNAL_DEFINITION
|
||||
|
||||
.struct _bfd_window_internal {
|
||||
. struct _bfd_window_internal *next;
|
||||
. void *data;
|
||||
. bfd_size_type size;
|
||||
. int refcount : 31; {* should be enough... *}
|
||||
. unsigned mapped : 1; {* 1 = mmap, 0 = malloc *}
|
||||
.};
|
||||
*/
|
||||
|
||||
void
|
||||
bfd_init_window (bfd_window *windowp)
|
||||
{
|
||||
windowp->data = 0;
|
||||
windowp->i = 0;
|
||||
windowp->size = 0;
|
||||
}
|
||||
|
||||
void
|
||||
bfd_free_window (bfd_window *windowp)
|
||||
{
|
||||
bfd_window_internal *i = windowp->i;
|
||||
windowp->i = 0;
|
||||
windowp->data = 0;
|
||||
if (i == 0)
|
||||
return;
|
||||
i->refcount--;
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "freeing window @%p<%p,%lx,%p>\n",
|
||||
windowp, windowp->data, windowp->size, windowp->i);
|
||||
if (i->refcount != 0)
|
||||
return;
|
||||
|
||||
if (i->mapped)
|
||||
{
|
||||
#ifdef HAVE_MMAP
|
||||
munmap (i->data, i->size);
|
||||
goto no_free;
|
||||
#else
|
||||
abort ();
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_MPROTECT
|
||||
mprotect (i->data, i->size, PROT_READ | PROT_WRITE);
|
||||
#endif
|
||||
free (i->data);
|
||||
#ifdef HAVE_MMAP
|
||||
no_free:
|
||||
#endif
|
||||
i->data = 0;
|
||||
/* There should be no more references to i at this point. */
|
||||
free (i);
|
||||
}
|
||||
|
||||
static int ok_to_map = 1;
|
||||
|
||||
bfd_boolean
|
||||
bfd_get_file_window (bfd *abfd,
|
||||
file_ptr offset,
|
||||
bfd_size_type size,
|
||||
bfd_window *windowp,
|
||||
bfd_boolean writable)
|
||||
{
|
||||
static size_t pagesize;
|
||||
bfd_window_internal *i = windowp->i;
|
||||
bfd_size_type size_to_alloc = size;
|
||||
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "bfd_get_file_window (%p, %6ld, %6ld, %p<%p,%lx,%p>, %d)",
|
||||
abfd, (long) offset, (long) size,
|
||||
windowp, windowp->data, (unsigned long) windowp->size,
|
||||
windowp->i, writable);
|
||||
|
||||
/* Make sure we know the page size, so we can be friendly to mmap. */
|
||||
if (pagesize == 0)
|
||||
pagesize = getpagesize ();
|
||||
if (pagesize == 0)
|
||||
abort ();
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = bfd_zmalloc (sizeof (bfd_window_internal));
|
||||
windowp->i = i;
|
||||
if (i == 0)
|
||||
return FALSE;
|
||||
i->data = 0;
|
||||
}
|
||||
#ifdef HAVE_MMAP
|
||||
if (ok_to_map
|
||||
&& (i->data == 0 || i->mapped == 1)
|
||||
&& (abfd->flags & BFD_IN_MEMORY) == 0)
|
||||
{
|
||||
file_ptr file_offset, offset2;
|
||||
size_t real_size;
|
||||
int fd;
|
||||
FILE *f;
|
||||
|
||||
/* Find the real file and the real offset into it. */
|
||||
while (abfd->my_archive != NULL)
|
||||
{
|
||||
offset += abfd->origin;
|
||||
abfd = abfd->my_archive;
|
||||
}
|
||||
f = bfd_cache_lookup (abfd);
|
||||
fd = fileno (f);
|
||||
|
||||
/* Compute offsets and size for mmap and for the user's data. */
|
||||
offset2 = offset % pagesize;
|
||||
if (offset2 < 0)
|
||||
abort ();
|
||||
file_offset = offset - offset2;
|
||||
real_size = offset + size - file_offset;
|
||||
real_size = real_size + pagesize - 1;
|
||||
real_size -= real_size % pagesize;
|
||||
|
||||
/* If we're re-using a memory region, make sure it's big enough. */
|
||||
if (i->data && i->size < size)
|
||||
{
|
||||
munmap (i->data, i->size);
|
||||
i->data = 0;
|
||||
}
|
||||
i->data = mmap (i->data, real_size,
|
||||
writable ? PROT_WRITE | PROT_READ : PROT_READ,
|
||||
(writable
|
||||
? MAP_FILE | MAP_PRIVATE
|
||||
: MAP_FILE | MAP_SHARED),
|
||||
fd, file_offset);
|
||||
if (i->data == (void *) -1)
|
||||
{
|
||||
/* An error happened. Report it, or try using malloc, or
|
||||
something. */
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
i->data = 0;
|
||||
windowp->data = 0;
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\t\tmmap failed!\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\n\tmapped %ld at %p, offset is %ld\n",
|
||||
(long) real_size, i->data, (long) offset2);
|
||||
i->size = real_size;
|
||||
windowp->data = (bfd_byte *) i->data + offset2;
|
||||
windowp->size = size;
|
||||
i->mapped = 1;
|
||||
return TRUE;
|
||||
}
|
||||
else if (debug_windows)
|
||||
{
|
||||
if (ok_to_map)
|
||||
fprintf (stderr, _("not mapping: data=%lx mapped=%d\n"),
|
||||
(unsigned long) i->data, (int) i->mapped);
|
||||
else
|
||||
fprintf (stderr, _("not mapping: env var not set\n"));
|
||||
}
|
||||
#else
|
||||
ok_to_map = 0;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MPROTECT
|
||||
if (!writable)
|
||||
{
|
||||
size_to_alloc += pagesize - 1;
|
||||
size_to_alloc -= size_to_alloc % pagesize;
|
||||
}
|
||||
#endif
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\n\t%s(%6ld)",
|
||||
i->data ? "realloc" : " malloc", (long) size_to_alloc);
|
||||
i->data = bfd_realloc (i->data, size_to_alloc);
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\t-> %p\n", i->data);
|
||||
i->refcount = 1;
|
||||
if (i->data == NULL)
|
||||
{
|
||||
if (size_to_alloc == 0)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
if (bfd_seek (abfd, offset, SEEK_SET) != 0)
|
||||
return FALSE;
|
||||
i->size = bfd_bread (i->data, size, abfd);
|
||||
if (i->size != size)
|
||||
return FALSE;
|
||||
i->mapped = 0;
|
||||
#ifdef HAVE_MPROTECT
|
||||
if (!writable)
|
||||
{
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\tmprotect (%p, %ld, PROT_READ)\n", i->data,
|
||||
(long) i->size);
|
||||
mprotect (i->data, i->size, PROT_READ);
|
||||
}
|
||||
#endif
|
||||
windowp->data = i->data;
|
||||
windowp->size = i->size;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif /* USE_MMAP */
|
||||
406
bfd/binary.c
406
bfd/binary.c
@@ -1,406 +0,0 @@
|
||||
/* BFD back-end for binary objects.
|
||||
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
2004 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This is a BFD backend which may be used to write binary objects.
|
||||
It may only be used for output, not input. The intention is that
|
||||
this may be used as an output format for objcopy in order to
|
||||
generate raw binary data.
|
||||
|
||||
This is very simple. The only complication is that the real data
|
||||
will start at some address X, and in some cases we will not want to
|
||||
include X zeroes just to get to that point. Since the start
|
||||
address is not meaningful for this object file format, we use it
|
||||
instead to indicate the number of zeroes to skip at the start of
|
||||
the file. objcopy cooperates by specially setting the start
|
||||
address to zero by default. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.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
|
||||
|
||||
static bfd_boolean binary_mkobject PARAMS ((bfd *));
|
||||
static const bfd_target *binary_object_p PARAMS ((bfd *));
|
||||
static bfd_boolean binary_get_section_contents
|
||||
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
|
||||
static long binary_get_symtab_upper_bound PARAMS ((bfd *));
|
||||
static char *mangle_name PARAMS ((bfd *, char *));
|
||||
static long binary_canonicalize_symtab PARAMS ((bfd *, asymbol **));
|
||||
static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
|
||||
static bfd_boolean binary_set_section_contents
|
||||
PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
|
||||
static int binary_sizeof_headers PARAMS ((bfd *, bfd_boolean));
|
||||
|
||||
/* Set by external programs - specifies the BFD architecture and
|
||||
machine number to be uses when creating binary BFDs. */
|
||||
enum bfd_architecture bfd_external_binary_architecture = bfd_arch_unknown;
|
||||
unsigned long bfd_external_machine = 0;
|
||||
|
||||
/* Create a binary object. Invoked via bfd_set_format. */
|
||||
|
||||
static bfd_boolean
|
||||
binary_mkobject (abfd)
|
||||
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 (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct stat statbuf;
|
||||
asection *sec;
|
||||
|
||||
if (abfd->target_defaulted)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
abfd->symcount = BIN_SYMS;
|
||||
|
||||
/* Find the file size. */
|
||||
if (bfd_stat (abfd, &statbuf) < 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* One data section. */
|
||||
sec = bfd_make_section (abfd, ".data");
|
||||
if (sec == NULL)
|
||||
return NULL;
|
||||
sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
|
||||
sec->vma = 0;
|
||||
sec->size = statbuf.st_size;
|
||||
sec->filepos = 0;
|
||||
|
||||
abfd->tdata.any = (PTR) sec;
|
||||
|
||||
if (bfd_get_arch_info (abfd) != NULL)
|
||||
{
|
||||
if ((bfd_get_arch_info (abfd)->arch == bfd_arch_unknown)
|
||||
&& (bfd_external_binary_architecture != bfd_arch_unknown))
|
||||
bfd_set_arch_info (abfd, bfd_lookup_arch
|
||||
(bfd_external_binary_architecture, bfd_external_machine));
|
||||
}
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
|
||||
#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
|
||||
#define binary_new_section_hook _bfd_generic_new_section_hook
|
||||
|
||||
/* Get contents of the only section. */
|
||||
|
||||
static bfd_boolean
|
||||
binary_get_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
asection *section ATTRIBUTE_UNUSED;
|
||||
PTR 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 (abfd)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return (BIN_SYMS + 1) * sizeof (asymbol *);
|
||||
}
|
||||
|
||||
/* Create a symbol name based on the bfd's filename. */
|
||||
|
||||
static char *
|
||||
mangle_name (abfd, suffix)
|
||||
bfd *abfd;
|
||||
char *suffix;
|
||||
{
|
||||
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 (abfd, alocation)
|
||||
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 0;
|
||||
|
||||
/* Start symbol. */
|
||||
syms[0].the_bfd = abfd;
|
||||
syms[0].name = mangle_name (abfd, "start");
|
||||
syms[0].value = 0;
|
||||
syms[0].flags = BSF_GLOBAL;
|
||||
syms[0].section = sec;
|
||||
syms[0].udata.p = NULL;
|
||||
|
||||
/* End symbol. */
|
||||
syms[1].the_bfd = abfd;
|
||||
syms[1].name = mangle_name (abfd, "end");
|
||||
syms[1].value = sec->size;
|
||||
syms[1].flags = BSF_GLOBAL;
|
||||
syms[1].section = sec;
|
||||
syms[1].udata.p = NULL;
|
||||
|
||||
/* Size symbol. */
|
||||
syms[2].the_bfd = abfd;
|
||||
syms[2].name = mangle_name (abfd, "size");
|
||||
syms[2].value = sec->size;
|
||||
syms[2].flags = BSF_GLOBAL;
|
||||
syms[2].section = bfd_abs_section_ptr;
|
||||
syms[2].udata.p = NULL;
|
||||
|
||||
for (i = 0; i < BIN_SYMS; i++)
|
||||
*alocation++ = syms++;
|
||||
*alocation = NULL;
|
||||
|
||||
return BIN_SYMS;
|
||||
}
|
||||
|
||||
#define binary_make_empty_symbol _bfd_generic_make_empty_symbol
|
||||
#define binary_print_symbol _bfd_nosymbols_print_symbol
|
||||
|
||||
/* Get information about a symbol. */
|
||||
|
||||
static void
|
||||
binary_get_symbol_info (ignore_abfd, symbol, ret)
|
||||
bfd *ignore_abfd ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol;
|
||||
symbol_info *ret;
|
||||
{
|
||||
bfd_symbol_info (symbol, ret);
|
||||
}
|
||||
|
||||
#define binary_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
|
||||
#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_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
#define binary_read_minisymbols _bfd_generic_read_minisymbols
|
||||
#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
|
||||
|
||||
#define binary_get_reloc_upper_bound \
|
||||
((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
|
||||
#define binary_canonicalize_reloc \
|
||||
((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
|
||||
#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
|
||||
|
||||
/* Set the architecture of a binary file. */
|
||||
#define binary_set_arch_mach _bfd_generic_set_arch_mach
|
||||
|
||||
/* Write section contents of a binary file. */
|
||||
|
||||
static bfd_boolean
|
||||
binary_set_section_contents (abfd, sec, data, offset, size)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
const PTR data;
|
||||
file_ptr offset;
|
||||
bfd_size_type size;
|
||||
{
|
||||
if (size == 0)
|
||||
return TRUE;
|
||||
|
||||
if (! abfd->output_has_begun)
|
||||
{
|
||||
bfd_boolean found_low;
|
||||
bfd_vma low;
|
||||
asection *s;
|
||||
|
||||
/* The lowest section LMA sets the virtual address of the start
|
||||
of the file. We use this to set the file position of all the
|
||||
sections. */
|
||||
found_low = FALSE;
|
||||
low = 0;
|
||||
for (s = abfd->sections; s != NULL; s = s->next)
|
||||
if (((s->flags
|
||||
& (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_NEVER_LOAD))
|
||||
== (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC))
|
||||
&& (s->size > 0)
|
||||
&& (! found_low || s->lma < low))
|
||||
{
|
||||
low = s->lma;
|
||||
found_low = TRUE;
|
||||
}
|
||||
|
||||
for (s = abfd->sections; s != NULL; s = s->next)
|
||||
{
|
||||
s->filepos = s->lma - low;
|
||||
|
||||
/* Skip following warning check for sections that will not
|
||||
occupy file space. */
|
||||
if ((s->flags
|
||||
& (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_NEVER_LOAD))
|
||||
!= (SEC_HAS_CONTENTS | SEC_ALLOC)
|
||||
|| (s->size == 0))
|
||||
continue;
|
||||
|
||||
/* If attempting to generate a binary file from a bfd with
|
||||
LMA's all over the place, huge (sparse?) binary files may
|
||||
result. This condition attempts to detect this situation
|
||||
and print a warning. Better heuristics would be nice to
|
||||
have. */
|
||||
|
||||
if (s->filepos < 0)
|
||||
(*_bfd_error_handler)
|
||||
(_("Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."),
|
||||
bfd_get_section_name (abfd, s),
|
||||
(unsigned long) s->filepos);
|
||||
}
|
||||
|
||||
abfd->output_has_begun = TRUE;
|
||||
}
|
||||
|
||||
/* We don't want to output anything for a section that is neither
|
||||
loaded nor allocated. The contents of such a section are not
|
||||
meaningful in the binary format. */
|
||||
if ((sec->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
|
||||
return TRUE;
|
||||
if ((sec->flags & SEC_NEVER_LOAD) != 0)
|
||||
return TRUE;
|
||||
|
||||
return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
|
||||
}
|
||||
|
||||
/* No space is required for header information. */
|
||||
|
||||
static int
|
||||
binary_sizeof_headers (abfd, exec)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_boolean exec ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define binary_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#define binary_bfd_relax_section bfd_generic_relax_section
|
||||
#define binary_bfd_gc_sections bfd_generic_gc_sections
|
||||
#define binary_bfd_merge_sections bfd_generic_merge_sections
|
||||
#define binary_bfd_is_group_section bfd_generic_is_group_section
|
||||
#define binary_bfd_discard_group bfd_generic_discard_group
|
||||
#define binary_section_already_linked \
|
||||
_bfd_generic_section_already_linked
|
||||
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
|
||||
#define binary_bfd_link_just_syms _bfd_generic_link_just_syms
|
||||
#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define binary_bfd_final_link _bfd_generic_final_link
|
||||
#define binary_bfd_link_split_section _bfd_generic_link_split_section
|
||||
#define binary_get_section_contents_in_window \
|
||||
_bfd_generic_get_section_contents_in_window
|
||||
|
||||
const bfd_target binary_vec =
|
||||
{
|
||||
"binary", /* name */
|
||||
bfd_target_unknown_flavour, /* flavour */
|
||||
BFD_ENDIAN_UNKNOWN, /* byteorder */
|
||||
BFD_ENDIAN_UNKNOWN, /* header_byteorder */
|
||||
EXEC_P, /* object_flags */
|
||||
(SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
|
||||
| SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
|
||||
0, /* symbol_leading_char */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target,
|
||||
binary_object_p, /* bfd_check_format */
|
||||
_bfd_dummy_target,
|
||||
_bfd_dummy_target,
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false,
|
||||
binary_mkobject,
|
||||
bfd_false,
|
||||
bfd_false,
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false,
|
||||
bfd_true,
|
||||
bfd_false,
|
||||
bfd_false,
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (binary),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (binary),
|
||||
BFD_JUMP_TABLE_RELOCS (binary),
|
||||
BFD_JUMP_TABLE_WRITE (binary),
|
||||
BFD_JUMP_TABLE_LINK (binary),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
NULL
|
||||
};
|
||||
1580
bfd/bout.c
1580
bfd/bout.c
File diff suppressed because it is too large
Load Diff
499
bfd/cache.c
499
bfd/cache.c
@@ -1,499 +0,0 @@
|
||||
/* BFD library -- caching of file descriptors.
|
||||
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002,
|
||||
2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/*
|
||||
SECTION
|
||||
File caching
|
||||
|
||||
The file caching mechanism is embedded within BFD and allows
|
||||
the application to open as many BFDs as it wants without
|
||||
regard to the underlying operating system's file descriptor
|
||||
limit (often as low as 20 open files). The module in
|
||||
<<cache.c>> maintains a least recently used list of
|
||||
<<BFD_CACHE_MAX_OPEN>> files, and exports the name
|
||||
<<bfd_cache_lookup>>, which runs around and makes sure that
|
||||
the required BFD is open. If not, then it chooses a file to
|
||||
close, closes it and opens the one wanted, returning its file
|
||||
handle.
|
||||
|
||||
*/
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
static bfd_boolean bfd_cache_delete (bfd *);
|
||||
|
||||
|
||||
static file_ptr
|
||||
cache_btell (struct bfd *abfd)
|
||||
{
|
||||
return real_ftell (bfd_cache_lookup (abfd));
|
||||
}
|
||||
|
||||
static int
|
||||
cache_bseek (struct bfd *abfd, file_ptr offset, int whence)
|
||||
{
|
||||
return real_fseek (bfd_cache_lookup (abfd), 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 (struct bfd *abfd, void *buf, file_ptr nbytes)
|
||||
{
|
||||
file_ptr nread;
|
||||
/* FIXME - this looks like an optimization, but it's really to cover
|
||||
up for a feature of some OSs (not solaris - sigh) that
|
||||
ld/pe-dll.c takes advantage of (apparently) when it creates BFDs
|
||||
internally and tries to link against them. BFD seems to be smart
|
||||
enough to realize there are no symbol records in the "file" that
|
||||
doesn't exist but attempts to read them anyway. On Solaris,
|
||||
attempting to read zero bytes from a NULL file results in a core
|
||||
dump, but on other platforms it just returns zero bytes read.
|
||||
This makes it to something reasonable. - DJ */
|
||||
if (nbytes == 0)
|
||||
return 0;
|
||||
|
||||
#if defined (__VAX) && defined (VMS)
|
||||
/* Apparently fread on Vax VMS does not keep the record length
|
||||
information. */
|
||||
nread = read (fileno (bfd_cache_lookup (abfd)), buf, nbytes);
|
||||
/* Set bfd_error if we did not read as much data as we expected. If
|
||||
the read failed due to an error set the bfd_error_system_call,
|
||||
else set bfd_error_file_truncated. */
|
||||
if (nread == (file_ptr)-1)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
nread = fread (buf, 1, nbytes, bfd_cache_lookup (abfd));
|
||||
/* 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 (bfd_cache_lookup (abfd)))
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return nread;
|
||||
}
|
||||
|
||||
static file_ptr
|
||||
cache_bwrite (struct bfd *abfd, const void *where, file_ptr nbytes)
|
||||
{
|
||||
file_ptr nwrite = fwrite (where, 1, nbytes, bfd_cache_lookup (abfd));
|
||||
if (nwrite < nbytes && ferror (bfd_cache_lookup (abfd)))
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return -1;
|
||||
}
|
||||
return nwrite;
|
||||
}
|
||||
|
||||
static int
|
||||
cache_bclose (struct bfd *abfd)
|
||||
{
|
||||
return bfd_cache_close (abfd);
|
||||
}
|
||||
|
||||
static int
|
||||
cache_bflush (struct bfd *abfd)
|
||||
{
|
||||
int sts = fflush (bfd_cache_lookup (abfd));
|
||||
if (sts < 0)
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return sts;
|
||||
}
|
||||
|
||||
static int
|
||||
cache_bstat (struct bfd *abfd, struct stat *sb)
|
||||
{
|
||||
int sts = fstat (fileno (bfd_cache_lookup (abfd)), sb);
|
||||
if (sts < 0)
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return sts;
|
||||
}
|
||||
|
||||
static const struct bfd_iovec cache_iovec = {
|
||||
&cache_bread, &cache_bwrite, &cache_btell, &cache_bseek,
|
||||
&cache_bclose, &cache_bflush, &cache_bstat
|
||||
};
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
BFD_CACHE_MAX_OPEN macro
|
||||
|
||||
DESCRIPTION
|
||||
The maximum number of files which the cache will keep open at
|
||||
one time.
|
||||
|
||||
.#define BFD_CACHE_MAX_OPEN 10
|
||||
|
||||
*/
|
||||
|
||||
/* The number of BFD files we have open. */
|
||||
|
||||
static int open_files;
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_last_cache
|
||||
|
||||
SYNOPSIS
|
||||
extern bfd *bfd_last_cache;
|
||||
|
||||
DESCRIPTION
|
||||
Zero, or a pointer to the topmost BFD on the chain. This is
|
||||
used by the <<bfd_cache_lookup>> macro in @file{libbfd.h} to
|
||||
determine when it can avoid a function call.
|
||||
*/
|
||||
|
||||
bfd *bfd_last_cache;
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_cache_lookup
|
||||
|
||||
DESCRIPTION
|
||||
Check to see if the required BFD is the same as the last one
|
||||
looked up. If so, then it can use the stream in the BFD with
|
||||
impunity, since it can't have changed since the last lookup;
|
||||
otherwise, it has to perform the complicated lookup function.
|
||||
|
||||
.#define bfd_cache_lookup(x) \
|
||||
. ((x) == bfd_last_cache ? \
|
||||
. (FILE *) (bfd_last_cache->iostream): \
|
||||
. bfd_cache_lookup_worker (x))
|
||||
|
||||
*/
|
||||
|
||||
/* Insert a BFD into the cache. */
|
||||
|
||||
static 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;
|
||||
}
|
||||
}
|
||||
|
||||
/* We need to open a new file, and the cache is full. Find the least
|
||||
recently used cacheable BFD and close it. */
|
||||
|
||||
static bfd_boolean
|
||||
close_one (void)
|
||||
{
|
||||
register bfd *kill;
|
||||
|
||||
if (bfd_last_cache == NULL)
|
||||
kill = NULL;
|
||||
else
|
||||
{
|
||||
for (kill = bfd_last_cache->lru_prev;
|
||||
! kill->cacheable;
|
||||
kill = kill->lru_prev)
|
||||
{
|
||||
if (kill == bfd_last_cache)
|
||||
{
|
||||
kill = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kill == NULL)
|
||||
{
|
||||
/* There are no open cacheable BFD's. */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
kill->where = real_ftell ((FILE *) kill->iostream);
|
||||
|
||||
return bfd_cache_delete (kill);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_cache_init
|
||||
|
||||
SYNOPSIS
|
||||
bfd_boolean bfd_cache_init (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Add a newly opened BFD to the cache.
|
||||
*/
|
||||
|
||||
bfd_boolean
|
||||
bfd_cache_init (bfd *abfd)
|
||||
{
|
||||
BFD_ASSERT (abfd->iostream != NULL);
|
||||
if (open_files >= BFD_CACHE_MAX_OPEN)
|
||||
{
|
||||
if (! close_one ())
|
||||
return FALSE;
|
||||
}
|
||||
abfd->iovec = &cache_iovec;
|
||||
insert (abfd);
|
||||
++open_files;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_cache_close
|
||||
|
||||
SYNOPSIS
|
||||
bfd_boolean bfd_cache_close (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Remove the BFD @var{abfd} from the cache. If the attached file is open,
|
||||
then close it too.
|
||||
|
||||
RETURNS
|
||||
<<FALSE>> is returned if closing the file fails, <<TRUE>> is
|
||||
returned if all is well.
|
||||
*/
|
||||
|
||||
bfd_boolean
|
||||
bfd_cache_close (bfd *abfd)
|
||||
{
|
||||
if (abfd->iovec != &cache_iovec)
|
||||
return TRUE;
|
||||
|
||||
if (abfd->iostream == NULL)
|
||||
/* Previously closed. */
|
||||
return TRUE;
|
||||
|
||||
return bfd_cache_delete (abfd);
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_cache_close_all
|
||||
|
||||
SYNOPSIS
|
||||
bfd_boolean bfd_cache_close_all (void);
|
||||
|
||||
DESCRIPTION
|
||||
Remove all BFDs from the cache. If the attached file is open,
|
||||
then close it too.
|
||||
|
||||
RETURNS
|
||||
<<FALSE>> is returned if closing one of the file fails, <<TRUE>> is
|
||||
returned if all is well.
|
||||
*/
|
||||
|
||||
bfd_boolean
|
||||
bfd_cache_close_all ()
|
||||
{
|
||||
bfd_boolean ret = TRUE;
|
||||
|
||||
while (bfd_last_cache != NULL)
|
||||
ret &= bfd_cache_close (bfd_last_cache);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_open_file
|
||||
|
||||
SYNOPSIS
|
||||
FILE* bfd_open_file (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Call the OS to open a file for @var{abfd}. Return the <<FILE *>>
|
||||
(possibly <<NULL>>) that results from this operation. Set up the
|
||||
BFD so that future accesses know the file is open. If the <<FILE *>>
|
||||
returned is <<NULL>>, then it won't have been put in the
|
||||
cache, so it won't have to be removed from it.
|
||||
*/
|
||||
|
||||
FILE *
|
||||
bfd_open_file (bfd *abfd)
|
||||
{
|
||||
abfd->cacheable = TRUE; /* Allow it to be closed later. */
|
||||
|
||||
if (open_files >= BFD_CACHE_MAX_OPEN)
|
||||
{
|
||||
if (! close_one ())
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (abfd->direction)
|
||||
{
|
||||
case read_direction:
|
||||
case no_direction:
|
||||
abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RB);
|
||||
break;
|
||||
case both_direction:
|
||||
case write_direction:
|
||||
if (abfd->opened_once)
|
||||
{
|
||||
abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB);
|
||||
if (abfd->iostream == NULL)
|
||||
abfd->iostream = (PTR) 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 (abfd->filename);
|
||||
#endif
|
||||
abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
|
||||
abfd->opened_once = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (abfd->iostream != NULL)
|
||||
{
|
||||
if (! bfd_cache_init (abfd))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (FILE *) abfd->iostream;
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_cache_lookup_worker
|
||||
|
||||
SYNOPSIS
|
||||
FILE *bfd_cache_lookup_worker (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Called when the macro <<bfd_cache_lookup>> fails to find a
|
||||
quick answer. Find a file descriptor for @var{abfd}. If
|
||||
necessary, it open it. If there are already more than
|
||||
<<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
|
||||
avoid running out of file descriptors. It will abort rather than
|
||||
returning NULL if it is unable to (re)open the @var{abfd}.
|
||||
*/
|
||||
|
||||
FILE *
|
||||
bfd_cache_lookup_worker (bfd *abfd)
|
||||
{
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
abort ();
|
||||
|
||||
if (abfd->my_archive)
|
||||
abfd = abfd->my_archive;
|
||||
|
||||
if (abfd->iostream != NULL)
|
||||
{
|
||||
/* Move the file to the start of the cache. */
|
||||
if (abfd != bfd_last_cache)
|
||||
{
|
||||
snip (abfd);
|
||||
insert (abfd);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bfd_open_file (abfd) == NULL
|
||||
|| abfd->where != (unsigned long) abfd->where
|
||||
|| real_fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
return (FILE *) abfd->iostream;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/* BFD back-end for Intel 386 COFF LynxOS files.
|
||||
Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#define TARGET_SYM i386lynx_coff_vec
|
||||
#define TARGET_NAME "coff-i386-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#include "coff-i386.c"
|
||||
@@ -1,28 +0,0 @@
|
||||
/* BFD back-end for Motorola M68K COFF LynxOS files.
|
||||
Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68klynx_coff_vec
|
||||
#define TARGET_NAME "coff-m68k-lynx"
|
||||
#define LYNXOS
|
||||
#define COFF_LONG_FILENAMES
|
||||
#define STATIC_RELOCS
|
||||
#define COFF_COMMON_ADDEND
|
||||
|
||||
#include "coff-m68k.c"
|
||||
@@ -1,28 +0,0 @@
|
||||
/* BFD back-end for Sparc COFF LynxOS files.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM sparclynx_coff_vec
|
||||
#define TARGET_NAME "coff-sparc-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#include "coff-sparc.c"
|
||||
429
bfd/cisco-core.c
429
bfd/cisco-core.c
@@ -1,429 +0,0 @@
|
||||
/* BFD back-end for CISCO crash dumps.
|
||||
Copyright 1994, 1997, 1999, 2000, 2001, 2002, 2004
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
/* core_file_failing_signal returns a host signal (this probably should
|
||||
be fixed). */
|
||||
#include <signal.h>
|
||||
|
||||
/* for MSVC builds */
|
||||
#ifndef SIGTRAP
|
||||
# define SIGTRAP 5
|
||||
#endif
|
||||
#ifndef SIGEMT
|
||||
# define SIGEMT 6
|
||||
#endif
|
||||
#ifndef SIGBUS
|
||||
# define SIGBUS 10
|
||||
#endif
|
||||
|
||||
int crash_info_locs[] = {
|
||||
0x0250, /* mips, ppc, x86, i960 */
|
||||
0x0400, /* m68k, mips, x86, i960 */
|
||||
0x0FFC, /* m68k, mips, ppc, x86, i960 */
|
||||
0x3000, /* ppc */
|
||||
0x4FFC, /* m68k */
|
||||
-1
|
||||
};
|
||||
|
||||
#define CRASH_MAGIC 0xdead1234
|
||||
#define MASK_ADDR(x) ((x) & 0x0fffffff) /* Mask crash info address */
|
||||
|
||||
typedef enum {
|
||||
CRASH_REASON_NOTCRASHED = 0,
|
||||
CRASH_REASON_EXCEPTION = 1,
|
||||
CRASH_REASON_CORRUPT = 2,
|
||||
} crashreason;
|
||||
|
||||
typedef struct {
|
||||
char magic[4]; /* Magic number */
|
||||
char version[4]; /* Version number */
|
||||
char reason[4]; /* Crash reason */
|
||||
char cpu_vector[4]; /* CPU vector for exceptions */
|
||||
char registers[4]; /* Pointer to saved registers */
|
||||
char rambase[4]; /* Base of RAM (not in V1 crash info) */
|
||||
char textbase[4]; /* Base of .text section (not in V3 crash info) */
|
||||
char database[4]; /* Base of .data section (not in V3 crash info) */
|
||||
char bssbase[4]; /* Base of .bss section (not in V3 crash info) */
|
||||
} crashinfo_external;
|
||||
|
||||
struct cisco_core_struct
|
||||
{
|
||||
int sig;
|
||||
};
|
||||
|
||||
static const bfd_target *cisco_core_file_validate PARAMS ((bfd *, int));
|
||||
static const bfd_target *cisco_core_file_p PARAMS ((bfd *));
|
||||
char *cisco_core_file_failing_command PARAMS ((bfd *));
|
||||
int cisco_core_file_failing_signal PARAMS ((bfd *));
|
||||
bfd_boolean cisco_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
|
||||
|
||||
/* Examine the file for a crash info struct at the offset given by
|
||||
CRASH_INFO_LOC. */
|
||||
|
||||
static const bfd_target *
|
||||
cisco_core_file_validate (abfd, crash_info_loc)
|
||||
bfd *abfd;
|
||||
int crash_info_loc;
|
||||
{
|
||||
char buf[4];
|
||||
unsigned int crashinfo_offset;
|
||||
crashinfo_external crashinfo;
|
||||
int nread;
|
||||
unsigned int magic;
|
||||
unsigned int version;
|
||||
unsigned int rambase;
|
||||
sec_ptr asect;
|
||||
struct stat statbuf;
|
||||
bfd_size_type amt;
|
||||
|
||||
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. */
|
||||
|
||||
asect = bfd_make_section_anyway (abfd, ".data");
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
/* 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. */
|
||||
|
||||
asect = bfd_make_section_anyway (abfd, ".crash");
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->flags = SEC_HAS_CONTENTS;
|
||||
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 (abfd, ".reg");
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->flags = SEC_HAS_CONTENTS;
|
||||
asect->vma = 0;
|
||||
asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase;
|
||||
/* Since we don't know the exact size of the saved register info,
|
||||
choose a register section size that is either the remaining part
|
||||
of the file, or 1024, whichever is smaller. */
|
||||
nread = statbuf.st_size - asect->filepos;
|
||||
asect->size = (nread < 1024) ? nread : 1024;
|
||||
|
||||
return abfd->xvec;
|
||||
|
||||
/* Get here if we have already started filling out the BFD
|
||||
and there is an error of some kind. */
|
||||
|
||||
error_return:
|
||||
bfd_release (abfd, abfd->tdata.any);
|
||||
abfd->tdata.any = NULL;
|
||||
bfd_section_list_clear (abfd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const bfd_target *
|
||||
cisco_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int *crash_info_locp;
|
||||
const bfd_target *target = NULL;
|
||||
|
||||
for (crash_info_locp = crash_info_locs;
|
||||
*crash_info_locp != -1 && target == NULL;
|
||||
crash_info_locp++)
|
||||
{
|
||||
target = cisco_core_file_validate (abfd, *crash_info_locp);
|
||||
}
|
||||
return (target);
|
||||
}
|
||||
|
||||
char *
|
||||
cisco_core_file_failing_command (abfd)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
cisco_core_file_failing_signal (abfd)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return abfd->tdata.cisco_core_data->sig;
|
||||
}
|
||||
|
||||
bfd_boolean
|
||||
cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd ATTRIBUTE_UNUSED;
|
||||
bfd *exec_bfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
extern const bfd_target cisco_core_little_vec;
|
||||
|
||||
const bfd_target cisco_core_big_vec =
|
||||
{
|
||||
"cisco-ios-core-big",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target, /* unknown format */
|
||||
_bfd_dummy_target, /* object file */
|
||||
_bfd_dummy_target, /* archive */
|
||||
cisco_core_file_p /* a core file */
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (cisco),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& cisco_core_little_vec,
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
||||
|
||||
const bfd_target cisco_core_little_vec =
|
||||
{
|
||||
"cisco-ios-core-little",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* target byte order */
|
||||
BFD_ENDIAN_LITTLE, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target, /* unknown format */
|
||||
_bfd_dummy_target, /* object file */
|
||||
_bfd_dummy_target, /* archive */
|
||||
cisco_core_file_p /* a core file */
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (cisco),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
&cisco_core_big_vec,
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
||||
584
bfd/coff-a29k.c
584
bfd/coff-a29k.c
@@ -1,584 +0,0 @@
|
||||
/* BFD back-end for AMD 29000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001,
|
||||
2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by David Wood at New York University 7/8/91.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define A29K 1
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/a29k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static long get_symbol_value PARAMS ((asymbol *));
|
||||
static bfd_reloc_status_type a29k_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean coff_a29k_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static bfd_boolean coff_a29k_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, bfd_boolean *));
|
||||
static void reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
#define INSERT_HWORD(WORD,HWORD) \
|
||||
(((WORD) & 0xff00ff00) | (((HWORD) & 0xff00) << 8) | ((HWORD)& 0xff))
|
||||
#define EXTRACT_HWORD(WORD) \
|
||||
((((WORD) & 0x00ff0000) >> 8) | ((WORD) & 0xff))
|
||||
#define SIGN_EXTEND_HWORD(HWORD) \
|
||||
(((HWORD) ^ 0x8000) - 0x8000)
|
||||
|
||||
/* Provided the symbol, returns the value reffed. */
|
||||
|
||||
static long
|
||||
get_symbol_value (symbol)
|
||||
asymbol *symbol;
|
||||
{
|
||||
long relocation = 0;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
relocation = 0;
|
||||
else
|
||||
relocation = symbol->value +
|
||||
symbol->section->output_section->vma +
|
||||
symbol->section->output_offset;
|
||||
|
||||
return relocation;
|
||||
}
|
||||
|
||||
/* This function is in charge of performing all the 29k relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol_in;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* The consth relocation comes in two parts, we have to remember
|
||||
the state between calls, in these variables. */
|
||||
static bfd_boolean part1_consth_active = FALSE;
|
||||
static unsigned long part1_consth_value;
|
||||
unsigned long insn;
|
||||
unsigned long sym_value;
|
||||
unsigned long unsigned_value;
|
||||
unsigned short r_type;
|
||||
long signed_value;
|
||||
unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
|
||||
bfd_byte *hit_data =addr + (bfd_byte *) (data);
|
||||
|
||||
r_type = reloc_entry->howto->type;
|
||||
|
||||
if (output_bfd)
|
||||
{
|
||||
/* Partial linking - do nothing. */
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
if (symbol_in != NULL
|
||||
&& bfd_is_und_section (symbol_in->section))
|
||||
{
|
||||
/* Keep the state machine happy in case we're called again. */
|
||||
if (r_type == R_IHIHALF)
|
||||
{
|
||||
part1_consth_active = TRUE;
|
||||
part1_consth_value = 0;
|
||||
}
|
||||
return bfd_reloc_undefined;
|
||||
}
|
||||
|
||||
if ((part1_consth_active) && (r_type != R_IHCONST))
|
||||
{
|
||||
part1_consth_active = FALSE;
|
||||
*error_message = (char *) _("Missing IHCONST");
|
||||
|
||||
return bfd_reloc_dangerous;
|
||||
}
|
||||
|
||||
sym_value = get_symbol_value(symbol_in);
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
case R_IREL:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
/* Take the value in the field and sign extend it. */
|
||||
signed_value = EXTRACT_HWORD(insn);
|
||||
signed_value = SIGN_EXTEND_HWORD(signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* See the note on the R_IREL reloc in coff_a29k_relocate_section. */
|
||||
if (signed_value == - (long) reloc_entry->address)
|
||||
signed_value = 0;
|
||||
|
||||
signed_value += sym_value + reloc_entry->addend;
|
||||
if ((signed_value & ~0x3ffff) == 0)
|
||||
{ /* Absolute jmp/call */
|
||||
insn |= (1 << 24); /* Make it absolute */
|
||||
/* FIXME: Should we change r_type to R_IABS. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Relative jmp/call, so subtract from the value the
|
||||
address of the place we're coming from. */
|
||||
signed_value -= (reloc_entry->address
|
||||
+ input_section->output_section->vma
|
||||
+ input_section->output_offset);
|
||||
if (signed_value > 0x1ffff || signed_value < -0x20000)
|
||||
return bfd_reloc_overflow;
|
||||
}
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_HWORD (insn, signed_value);
|
||||
bfd_put_32 (abfd, (bfd_vma) insn ,hit_data);
|
||||
break;
|
||||
case R_ILOHALF:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
unsigned_value = EXTRACT_HWORD(insn);
|
||||
unsigned_value += sym_value + reloc_entry->addend;
|
||||
insn = INSERT_HWORD(insn, unsigned_value);
|
||||
bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
|
||||
break;
|
||||
case R_IHIHALF:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
/* consth, part 1
|
||||
Just get the symbol value that is referenced. */
|
||||
part1_consth_active = TRUE;
|
||||
part1_consth_value = sym_value + reloc_entry->addend;
|
||||
/* Don't modify insn until R_IHCONST. */
|
||||
break;
|
||||
case R_IHCONST:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
/* consth, part 2
|
||||
Now relocate the reference. */
|
||||
if (! part1_consth_active)
|
||||
{
|
||||
*error_message = (char *) _("Missing IHIHALF");
|
||||
return bfd_reloc_dangerous;
|
||||
}
|
||||
/* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */
|
||||
unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/
|
||||
unsigned_value += reloc_entry->addend; /* r_symndx */
|
||||
unsigned_value += part1_consth_value;
|
||||
unsigned_value = unsigned_value >> 16;
|
||||
insn = INSERT_HWORD(insn, unsigned_value);
|
||||
part1_consth_active = FALSE;
|
||||
bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
|
||||
break;
|
||||
case R_BYTE:
|
||||
insn = bfd_get_8 (abfd, hit_data);
|
||||
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||
if (unsigned_value & 0xffffff00)
|
||||
return bfd_reloc_overflow;
|
||||
bfd_put_8 (abfd, unsigned_value, hit_data);
|
||||
break;
|
||||
case R_HWORD:
|
||||
insn = bfd_get_16 (abfd, hit_data);
|
||||
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||
if (unsigned_value & 0xffff0000)
|
||||
return bfd_reloc_overflow;
|
||||
bfd_put_16 (abfd, (bfd_vma) insn, hit_data);
|
||||
break;
|
||||
case R_WORD:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
insn += sym_value + reloc_entry->addend;
|
||||
bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
|
||||
break;
|
||||
default:
|
||||
*error_message = _("Unrecognized reloc");
|
||||
return bfd_reloc_dangerous;
|
||||
}
|
||||
|
||||
return(bfd_reloc_ok);
|
||||
}
|
||||
|
||||
/*FIXME: I'm not real sure about this table. */
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{R_ABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield,a29k_reloc,"ABS", TRUE, 0xffffffff,0xffffffff, FALSE},
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
EMPTY_HOWTO (6),
|
||||
EMPTY_HOWTO (7),
|
||||
EMPTY_HOWTO (8),
|
||||
EMPTY_HOWTO (9),
|
||||
EMPTY_HOWTO (10),
|
||||
EMPTY_HOWTO (11),
|
||||
EMPTY_HOWTO (12),
|
||||
EMPTY_HOWTO (13),
|
||||
EMPTY_HOWTO (14),
|
||||
EMPTY_HOWTO (15),
|
||||
EMPTY_HOWTO (16),
|
||||
EMPTY_HOWTO (17),
|
||||
EMPTY_HOWTO (18),
|
||||
EMPTY_HOWTO (19),
|
||||
EMPTY_HOWTO (20),
|
||||
EMPTY_HOWTO (21),
|
||||
EMPTY_HOWTO (22),
|
||||
EMPTY_HOWTO (23),
|
||||
{R_IREL, 0, 3, 32, TRUE, 0, complain_overflow_signed,a29k_reloc,"IREL", TRUE, 0xffffffff,0xffffffff, FALSE},
|
||||
{R_IABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, a29k_reloc,"IABS", TRUE, 0xffffffff,0xffffffff, FALSE},
|
||||
{R_ILOHALF, 0, 3, 16, TRUE, 0, complain_overflow_signed, a29k_reloc,"ILOHALF", TRUE, 0x0000ffff,0x0000ffff, FALSE},
|
||||
{R_IHIHALF, 0, 3, 16, TRUE, 16, complain_overflow_signed, a29k_reloc,"IHIHALF", TRUE, 0xffff0000,0xffff0000, FALSE},
|
||||
{R_IHCONST, 0, 3, 16, TRUE, 0, complain_overflow_signed, a29k_reloc,"IHCONST", TRUE, 0xffff0000,0xffff0000, FALSE},
|
||||
{R_BYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, a29k_reloc,"BYTE", TRUE, 0x000000ff,0x000000ff, FALSE},
|
||||
{R_HWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, a29k_reloc,"HWORD", TRUE, 0x0000ffff,0x0000ffff, FALSE},
|
||||
{R_WORD, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, a29k_reloc,"WORD", TRUE, 0xffffffff,0xffffffff, FALSE},
|
||||
};
|
||||
|
||||
#define BADMAG(x) A29KBADMAG(x)
|
||||
|
||||
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent,reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
|
||||
|
||||
relent->address = reloc->r_vaddr;
|
||||
relent->howto = howto_table + reloc->r_type;
|
||||
if (reloc->r_type == R_IHCONST)
|
||||
{
|
||||
/* The address of an R_IHCONST should always be the address of
|
||||
the immediately preceding R_IHIHALF. relocs generated by gas
|
||||
are correct, but relocs generated by High C are different (I
|
||||
can't figure out what the address means for High C). We can
|
||||
handle both gas and High C by ignoring the address here, and
|
||||
simply reusing the address saved for R_IHIHALF. */
|
||||
if (ihihalf_vaddr == (bfd_vma) -1)
|
||||
abort ();
|
||||
relent->address = ihihalf_vaddr;
|
||||
ihihalf_vaddr = (bfd_vma) -1;
|
||||
relent->addend = reloc->r_symndx;
|
||||
relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
asymbol *ptr;
|
||||
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
|
||||
if (ptr
|
||||
&& bfd_asymbol_bfd(ptr) == abfd
|
||||
&& ((ptr->flags & BSF_OLD_COMMON) == 0))
|
||||
relent->addend = 0;
|
||||
else
|
||||
relent->addend = 0;
|
||||
|
||||
relent->address-= section->vma;
|
||||
if (reloc->r_type == R_IHIHALF)
|
||||
ihihalf_vaddr = relent->address;
|
||||
else if (ihihalf_vaddr != (bfd_vma) -1)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
struct internal_reloc *rel;
|
||||
struct internal_reloc *relend;
|
||||
bfd_boolean hihalf;
|
||||
bfd_vma hihalf_val;
|
||||
|
||||
/* If we are performing a relocatable link, we don't need to do a
|
||||
thing. The caller will take care of adjusting the reloc
|
||||
addresses and symbol indices. */
|
||||
if (info->relocatable)
|
||||
return TRUE;
|
||||
|
||||
hihalf = FALSE;
|
||||
hihalf_val = 0;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
bfd_byte *loc;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
asection *sec;
|
||||
bfd_vma val;
|
||||
bfd_boolean overflow;
|
||||
unsigned long insn;
|
||||
long signed_value;
|
||||
unsigned long unsigned_value;
|
||||
bfd_reloc_status_type rstat;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
loc = contents + rel->r_vaddr - input_section->vma;
|
||||
|
||||
if (symndx == -1 || rel->r_type == R_IHCONST)
|
||||
h = NULL;
|
||||
else
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
|
||||
sym = NULL;
|
||||
sec = NULL;
|
||||
val = 0;
|
||||
|
||||
/* An R_IHCONST reloc does not have a symbol. Instead, the
|
||||
symbol index is an addend. R_IHCONST is always used in
|
||||
conjunction with R_IHHALF. */
|
||||
if (rel->r_type != R_IHCONST)
|
||||
{
|
||||
if (h == NULL)
|
||||
{
|
||||
if (symndx == -1)
|
||||
sec = bfd_abs_section_ptr;
|
||||
else
|
||||
{
|
||||
sym = syms + symndx;
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value
|
||||
- sec->vma);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma, TRUE)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (hihalf)
|
||||
{
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info, _("missing IHCONST reloc"), input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
hihalf = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
overflow = FALSE;
|
||||
|
||||
switch (rel->r_type)
|
||||
{
|
||||
default:
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return FALSE;
|
||||
|
||||
case R_IREL:
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
|
||||
/* Extract the addend. */
|
||||
signed_value = EXTRACT_HWORD (insn);
|
||||
signed_value = SIGN_EXTEND_HWORD (signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* Unfortunately, there are two different versions of COFF
|
||||
a29k. In the original AMD version, the value stored in
|
||||
the field for the R_IREL reloc is a simple addend. In
|
||||
the GNU version, the value is the negative of the address
|
||||
of the reloc within section. We try to cope here by
|
||||
assuming the AMD version, unless the addend is exactly
|
||||
the negative of the address; in the latter case we assume
|
||||
the GNU version. This means that something like
|
||||
.text
|
||||
nop
|
||||
jmp i-4
|
||||
will fail, because the addend of -4 will happen to equal
|
||||
the negative of the address within the section. The
|
||||
compiler will never generate code like this.
|
||||
|
||||
At some point in the future we may want to take out this
|
||||
check. */
|
||||
|
||||
if (signed_value == - (long) (rel->r_vaddr - input_section->vma))
|
||||
signed_value = 0;
|
||||
|
||||
/* Determine the destination of the jump. */
|
||||
signed_value += val;
|
||||
|
||||
if ((signed_value & ~0x3ffff) == 0)
|
||||
{
|
||||
/* We can use an absolute jump. */
|
||||
insn |= (1 << 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make the destination PC relative. */
|
||||
signed_value -= (input_section->output_section->vma
|
||||
+ input_section->output_offset
|
||||
+ (rel->r_vaddr - input_section->vma));
|
||||
if (signed_value > 0x1ffff || signed_value < - 0x20000)
|
||||
{
|
||||
overflow = TRUE;
|
||||
signed_value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Put the adjusted value back into the instruction. */
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_HWORD (insn, signed_value);
|
||||
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
break;
|
||||
|
||||
case R_ILOHALF:
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
unsigned_value = EXTRACT_HWORD (insn);
|
||||
unsigned_value += val;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
break;
|
||||
|
||||
case R_IHIHALF:
|
||||
/* Save the value for the R_IHCONST reloc. */
|
||||
hihalf = TRUE;
|
||||
hihalf_val = val;
|
||||
break;
|
||||
|
||||
case R_IHCONST:
|
||||
if (! hihalf)
|
||||
{
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info, _("missing IHIHALF reloc"), input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
hihalf_val = 0;
|
||||
}
|
||||
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
unsigned_value = rel->r_symndx + hihalf_val;
|
||||
unsigned_value >>= 16;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
|
||||
hihalf = FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case R_BYTE:
|
||||
case R_HWORD:
|
||||
case R_WORD:
|
||||
rstat = _bfd_relocate_contents (howto_table + rel->r_type,
|
||||
input_bfd, val, loc);
|
||||
if (rstat == bfd_reloc_overflow)
|
||||
overflow = TRUE;
|
||||
else if (rstat != bfd_reloc_ok)
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else if (sym == NULL)
|
||||
name = "*unknown*";
|
||||
else if (sym->_n._n_n._n_zeroes == 0
|
||||
&& sym->_n._n_n._n_offset != 0)
|
||||
name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
|
||||
else
|
||||
{
|
||||
strncpy (buf, sym->_n._n_name, SYMNMLEN);
|
||||
buf[SYMNMLEN] = '\0';
|
||||
name = buf;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto_table[rel->r_type].name, (bfd_vma) 0,
|
||||
input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define coff_relocate_section coff_a29k_relocate_section
|
||||
|
||||
/* We don't want to change the symndx of a R_IHCONST reloc, since it
|
||||
is actually an addend, not a symbol index at all. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
||||
bfd *ibfd ATTRIBUTE_UNUSED;
|
||||
asection *sec ATTRIBUTE_UNUSED;
|
||||
struct internal_reloc *irel;
|
||||
bfd_boolean *adjustedp;
|
||||
{
|
||||
if (irel->r_type == R_IHCONST)
|
||||
*adjustedp = TRUE;
|
||||
else
|
||||
*adjustedp = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define coff_adjust_symndx coff_a29k_adjust_symndx
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (a29kcoff_big_vec, "coff-a29k-big", 0, SEC_READONLY, '_', NULL, COFF_SWAP_TABLE)
|
||||
2404
bfd/coff-alpha.c
2404
bfd/coff-alpha.c
File diff suppressed because it is too large
Load Diff
@@ -1,121 +0,0 @@
|
||||
/* BFD back-end for Apollo 68000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1999, 2000, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
By Troy Rollo (troy@cbme.unsw.edu.au)
|
||||
Based on m68k standard COFF version Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/apollo.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern reloc_howto_type apollocoff_howto_table[];
|
||||
#else
|
||||
reloc_howto_type apollocoff_howto_table[] =
|
||||
{
|
||||
HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
HOWTO (R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, "DISP8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "DISP16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "DISP32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
HOWTO (R_RELLONG_NEG, 0, -2, 32, FALSE, 0, complain_overflow_bitfield, 0, "-32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
};
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#ifndef BADMAG
|
||||
#define BADMAG(x) M68KBADMAG(x)
|
||||
#endif
|
||||
#define APOLLO_M68 1 /* Customize coffcode.h */
|
||||
|
||||
/* Turn a howto into a reloc number. */
|
||||
|
||||
extern void apollo_rtype2howto PARAMS ((arelent *, int));
|
||||
extern int apollo_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
#ifndef ONLY_DECLARE_RELOCS
|
||||
|
||||
void
|
||||
apollo_rtype2howto (internal, relocentry)
|
||||
arelent *internal;
|
||||
int relocentry;
|
||||
{
|
||||
switch (relocentry)
|
||||
{
|
||||
case R_RELBYTE: internal->howto = apollocoff_howto_table + 0; break;
|
||||
case R_RELWORD: internal->howto = apollocoff_howto_table + 1; break;
|
||||
case R_RELLONG: internal->howto = apollocoff_howto_table + 2; break;
|
||||
case R_PCRBYTE: internal->howto = apollocoff_howto_table + 3; break;
|
||||
case R_PCRWORD: internal->howto = apollocoff_howto_table + 4; break;
|
||||
case R_PCRLONG: internal->howto = apollocoff_howto_table + 5; break;
|
||||
case R_RELLONG_NEG: internal->howto = apollocoff_howto_table + 6; break;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
apollo_howto2rtype (internal)
|
||||
reloc_howto_type *internal;
|
||||
{
|
||||
if (internal->pc_relative)
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_PCRLONG;
|
||||
case 16: return R_PCRWORD;
|
||||
case 8: return R_PCRBYTE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_RELLONG;
|
||||
case 16: return R_RELWORD;
|
||||
case 8: return R_RELBYTE;
|
||||
}
|
||||
}
|
||||
return R_RELLONG;
|
||||
}
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) \
|
||||
apollo_rtype2howto (internal, (relocentry)->r_type)
|
||||
|
||||
#define SELECT_RELOC(external, internal) \
|
||||
external.r_type = apollo_howto2rtype (internal);
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifndef TARGET_SYM
|
||||
#define TARGET_SYM apollocoff_vec
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_NAME
|
||||
#define TARGET_NAME "apollo-m68k"
|
||||
#endif
|
||||
|
||||
#ifdef NAMES_HAVE_UNDERSCORE
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
#else
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, 0, NULL, COFF_SWAP_TABLE)
|
||||
#endif
|
||||
2621
bfd/coff-arm.c
2621
bfd/coff-arm.c
File diff suppressed because it is too large
Load Diff
135
bfd/coff-aux.c
135
bfd/coff-aux.c
@@ -1,135 +0,0 @@
|
||||
/* BFD back-end for Apple M68K COFF A/UX 3.x files.
|
||||
Copyright 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Richard Henderson <rth@tamu.edu>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68kaux_coff_vec
|
||||
#define TARGET_NAME "coff-m68k-aux"
|
||||
|
||||
#ifndef TARG_AUX
|
||||
#define TARG_AUX
|
||||
#endif
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
/* 4k pages */
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* On AUX, a STYP_NOLOAD|STYP_BSS section is part of a shared library. */
|
||||
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||
|
||||
#define STATIC_RELOCS
|
||||
|
||||
#define COFF_COMMON_ADDEND
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
static bfd_boolean coff_m68k_aux_link_add_one_symbol
|
||||
PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
|
||||
asection *, bfd_vma, const char *, bfd_boolean, bfd_boolean,
|
||||
struct bfd_link_hash_entry **));
|
||||
|
||||
#define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
|
||||
|
||||
#include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */
|
||||
#include "coff-m68k.c"
|
||||
|
||||
/* We need non-absolute symbols to override absolute symbols. This
|
||||
mirrors Apple's "solution" to let a static library symbol override
|
||||
a shared library symbol. On the whole not a good thing, given how
|
||||
shared libraries work here, but can work if you are careful with
|
||||
what you include in the shared object. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value,
|
||||
string, copy, collect, hashp)
|
||||
struct bfd_link_info *info;
|
||||
bfd *abfd;
|
||||
const char *name;
|
||||
flagword flags;
|
||||
asection *section;
|
||||
bfd_vma value;
|
||||
const char *string;
|
||||
bfd_boolean copy;
|
||||
bfd_boolean collect;
|
||||
struct bfd_link_hash_entry **hashp;
|
||||
{
|
||||
struct bfd_link_hash_entry *h;
|
||||
|
||||
if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 &&
|
||||
!bfd_is_und_section (section) &&
|
||||
!bfd_is_com_section (section))
|
||||
{
|
||||
/* The new symbol is a definition or an indirect definition */
|
||||
|
||||
/* This bit copied from linker.c */
|
||||
if (hashp != NULL && *hashp != NULL)
|
||||
{
|
||||
h = *hashp;
|
||||
BFD_ASSERT (strcmp (h->root.string, name) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
h = bfd_link_hash_lookup (info->hash, name, TRUE, copy, FALSE);
|
||||
if (h == NULL)
|
||||
{
|
||||
if (hashp != NULL)
|
||||
*hashp = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (info->notice_hash != (struct bfd_hash_table *) NULL
|
||||
&& (bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE)
|
||||
!= (struct bfd_hash_entry *) NULL))
|
||||
{
|
||||
if (! (*info->callbacks->notice) (info, name, abfd, section, value))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (hashp != (struct bfd_link_hash_entry **) NULL)
|
||||
*hashp = h;
|
||||
/* end duplication from linker.c */
|
||||
|
||||
if (h->type == bfd_link_hash_defined
|
||||
|| h->type == bfd_link_hash_indirect)
|
||||
{
|
||||
asection *msec;
|
||||
|
||||
if (h->type == bfd_link_hash_defined)
|
||||
msec = h->u.def.section;
|
||||
else
|
||||
msec = bfd_ind_section_ptr;
|
||||
|
||||
if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section))
|
||||
{
|
||||
h->u.def.section = section;
|
||||
h->u.def.value = value;
|
||||
return TRUE;
|
||||
}
|
||||
else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't exit early, finish processing in the generic routine */
|
||||
return _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
|
||||
value, string, copy, collect,
|
||||
hashp);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/* BFD back-end for Intel 386 COFF files (DJGPP variant).
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1999, 2000, 2001
|
||||
Free Software Foundation, Inc.
|
||||
Written by DJ Delorie.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM go32coff_vec
|
||||
#define TARGET_NAME "coff-go32"
|
||||
#define TARGET_UNDERSCORE '_'
|
||||
#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"
|
||||
1444
bfd/coff-h8300.c
1444
bfd/coff-h8300.c
File diff suppressed because it is too large
Load Diff
306
bfd/coff-h8500.c
306
bfd/coff-h8500.c
@@ -1,306 +0,0 @@
|
||||
/* BFD back-end for Renesas H8/500 COFF binaries.
|
||||
Copyright 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Support.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/h8500.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static int coff_h8500_select_reloc PARAMS ((reloc_howto_type *));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
static void extra_case PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, bfd_byte *, unsigned int *, unsigned int *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
static reloc_howto_type r_imm8 =
|
||||
HOWTO (R_H8500_IMM8, 0, 1, 8, FALSE, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm8", TRUE, 0x000000ff, 0x000000ff, FALSE);
|
||||
|
||||
static reloc_howto_type r_imm16 =
|
||||
HOWTO (R_H8500_IMM16, 0, 1, 16, FALSE, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm16", TRUE, 0x0000ffff, 0x0000ffff, FALSE);
|
||||
|
||||
static reloc_howto_type r_imm24 =
|
||||
HOWTO (R_H8500_IMM24, 0, 1, 24, FALSE, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm24", TRUE, 0x00ffffff, 0x00ffffff, FALSE);
|
||||
|
||||
static reloc_howto_type r_imm32 =
|
||||
HOWTO (R_H8500_IMM32, 0, 1, 32, FALSE, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm32", TRUE, 0xffffffff, 0xffffffff, FALSE);
|
||||
|
||||
static reloc_howto_type r_high8 =
|
||||
HOWTO (R_H8500_HIGH8, 0, 1, 8, FALSE, 0,
|
||||
complain_overflow_dont, 0, "r_high8", TRUE, 0x000000ff, 0x000000ff, FALSE);
|
||||
|
||||
static reloc_howto_type r_low16 =
|
||||
HOWTO (R_H8500_LOW16, 0, 1, 16, FALSE, 0,
|
||||
complain_overflow_dont, 0, "r_low16", TRUE, 0x0000ffff, 0x0000ffff, FALSE);
|
||||
|
||||
static reloc_howto_type r_pcrel8 =
|
||||
HOWTO (R_H8500_PCREL8, 0, 1, 8, TRUE, 0, complain_overflow_signed, 0, "r_pcrel8", TRUE, 0, 0, TRUE);
|
||||
|
||||
static reloc_howto_type r_pcrel16 =
|
||||
HOWTO (R_H8500_PCREL16, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "r_pcrel16", TRUE, 0, 0, TRUE);
|
||||
|
||||
static reloc_howto_type r_high16 =
|
||||
HOWTO (R_H8500_HIGH16, 0, 1, 8, FALSE, 0,
|
||||
complain_overflow_dont, 0, "r_high16", TRUE, 0x000ffff, 0x0000ffff, FALSE);
|
||||
|
||||
/* Turn a howto into a reloc number. */
|
||||
|
||||
static int
|
||||
coff_h8500_select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
#define SELECT_RELOC(x,howto) x.r_type = coff_h8500_select_reloc(howto)
|
||||
|
||||
#define BADMAG(x) H8500BADMAG(x)
|
||||
#define H8500 1 /* Customize coffcode.h */
|
||||
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Code to swap in the reloc. */
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table. */
|
||||
|
||||
static void
|
||||
rtype2howto (internal, dst)
|
||||
arelent * internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
switch (dst->r_type)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
case R_H8500_IMM8:
|
||||
internal->howto = &r_imm8;
|
||||
break;
|
||||
case R_H8500_IMM16:
|
||||
internal->howto = &r_imm16;
|
||||
break;
|
||||
case R_H8500_IMM24:
|
||||
internal->howto = &r_imm24;
|
||||
break;
|
||||
case R_H8500_IMM32:
|
||||
internal->howto = &r_imm32;
|
||||
break;
|
||||
case R_H8500_PCREL8:
|
||||
internal->howto = &r_pcrel8;
|
||||
break;
|
||||
case R_H8500_PCREL16:
|
||||
internal->howto = &r_pcrel16;
|
||||
break;
|
||||
case R_H8500_HIGH8:
|
||||
internal->howto = &r_high8;
|
||||
break;
|
||||
case R_H8500_HIGH16:
|
||||
internal->howto = &r_high16;
|
||||
break;
|
||||
case R_H8500_LOW16:
|
||||
internal->howto = &r_low16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
/* Perform any necessary magic to the addend in a reloc entry. */
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent * relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol ** symbols;
|
||||
bfd * abfd;
|
||||
asection * section;
|
||||
{
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (reloc->r_symndx > 0)
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
else
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
relent->address -= section->vma;
|
||||
}
|
||||
|
||||
static void
|
||||
extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
|
||||
bfd *in_abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
bfd_byte *d = data+*dst_ptr;
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_H8500_IMM8:
|
||||
bfd_put_8 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d);
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_H8500_HIGH8:
|
||||
bfd_put_8 (in_abfd,
|
||||
(bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
>> 16),
|
||||
d);
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_H8500_IMM16:
|
||||
bfd_put_16 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_LOW16:
|
||||
bfd_put_16 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d);
|
||||
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_HIGH16:
|
||||
bfd_put_16 (in_abfd,
|
||||
(bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
>> 16),
|
||||
d);
|
||||
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_IMM24:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
int o = bfd_get_32 (in_abfd, data+ *dst_ptr -1);
|
||||
v = (v & 0x00ffffff) | (o & 0xff00000);
|
||||
bfd_put_32 (in_abfd, (bfd_vma) v, data + *dst_ptr -1);
|
||||
(*dst_ptr) += 3;
|
||||
(*src_ptr) += 3;;
|
||||
}
|
||||
break;
|
||||
case R_H8500_IMM32:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
bfd_put_32 (in_abfd, (bfd_vma) v, data + *dst_ptr);
|
||||
(*dst_ptr) += 4;
|
||||
(*src_ptr) += 4;;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_H8500_PCREL8:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ *dst_ptr
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = dst - dot - 1; /* -1 since were in the odd byte of the
|
||||
word and the pc's been incremented. */
|
||||
|
||||
if (gap > 128 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_8 (in_abfd, gap, data + *dst_ptr);
|
||||
(*dst_ptr)++;
|
||||
(*src_ptr)++;
|
||||
break;
|
||||
}
|
||||
case R_H8500_PCREL16:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ *dst_ptr
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = dst - dot - 1; /* -1 since were in the odd byte of the
|
||||
word and the pc's been incremented. */
|
||||
|
||||
if (gap > 32767 || gap < -32768)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_16 (in_abfd, (bfd_vma) gap, data + *dst_ptr);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases extra_case
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (h8500coff_vec, "coff-h8500", 0, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
669
bfd/coff-i386.c
669
bfd/coff-i386.c
@@ -1,669 +0,0 @@
|
||||
/* BFD back-end for Intel 386 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "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
|
||||
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_reloc_status_type coff_i386_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_i386_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
static reloc_howto_type *coff_i386_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* For some reason when using i386 COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. Ian Taylor, Cygnus Support. */
|
||||
|
||||
/* If we are producing relocatable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
#endif
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
#ifndef COFF_WITH_PE
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
#else
|
||||
/* In PE mode, we do not offset the common symbol. */
|
||||
diff = reloc_entry->addend;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocatable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
#ifdef COFF_WITH_PE
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
|
||||
/* Although PC relative relocations are very similar between
|
||||
PE and non-PE formats, but they are off by 1 << howto->size
|
||||
bytes. For the external relocation, PE is very different
|
||||
from others. See md_apply_fix3 () in gas/config/tc-i386.c.
|
||||
When we link PE and non-PE object files together to
|
||||
generate a non-PE executable, we have to compensate it
|
||||
here. */
|
||||
if (howto->pc_relative && howto->pcrel_offset)
|
||||
diff = -(1 << howto->size);
|
||||
else
|
||||
diff = -reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
/* FIXME: How should this case be handled? */
|
||||
if (reloc_entry->howto->type == R_IMAGEBASE
|
||||
&& output_bfd != NULL
|
||||
&& bfd_get_flavour(output_bfd) == bfd_target_coff_flavour)
|
||||
diff -= pe_data (output_bfd)->pe_opthdr.ImageBase;
|
||||
#endif
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
/* Return TRUE if this relocation should appear in the output .reloc
|
||||
section. */
|
||||
|
||||
static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
|
||||
|
||||
static bfd_boolean in_reloc_p (abfd, howto)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return ! howto->pc_relative && howto->type != R_IMAGEBASE;
|
||||
}
|
||||
#endif /* COFF_WITH_PE */
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET FALSE
|
||||
#endif
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
HOWTO (R_DIR32, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"dir32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
/* PE IMAGE_REL_I386_DIR32NB relocation (7). */
|
||||
HOWTO (R_IMAGEBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"rva32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
EMPTY_HOWTO (010),
|
||||
EMPTY_HOWTO (011),
|
||||
EMPTY_HOWTO (012),
|
||||
#ifdef COFF_WITH_PE
|
||||
/* 32-bit longword section relative relocation (013). */
|
||||
HOWTO (R_SECREL32, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"secrel32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
#else
|
||||
EMPTY_HOWTO (013),
|
||||
#endif
|
||||
EMPTY_HOWTO (014),
|
||||
EMPTY_HOWTO (015),
|
||||
EMPTY_HOWTO (016),
|
||||
/* Byte relocation (017). */
|
||||
HOWTO (R_RELBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"8", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 16-bit word relocation (020). */
|
||||
HOWTO (R_RELWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"16", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 32-bit longword relocation (021). */
|
||||
HOWTO (R_RELLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* Byte PC relative relocation (022). */
|
||||
HOWTO (R_PCRBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP8", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 16-bit word PC relative relocation (023). */
|
||||
HOWTO (R_PCRWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP16", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 32-bit longword PC relative relocation (024). */
|
||||
HOWTO (R_PCRLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) I386BADMAG(x)
|
||||
#define I386 1 /* Customize coffcode.h */
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
((cache_ptr)->howto = \
|
||||
((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \
|
||||
? howto_table + (dst)->r_type \
|
||||
: NULL))
|
||||
|
||||
/* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
|
||||
library. On some other COFF targets STYP_BSS is normally
|
||||
STYP_NOLOAD. */
|
||||
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||
|
||||
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||
the object file contains the value of the common symbol. By the
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && howto_table[reloc.r_type].pc_relative) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
/* We use the special COFF backend linker. For normal i386 COFF, we
|
||||
can use the generic relocate_section routine. For PE, we need our
|
||||
own routine. */
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
#else /* COFF_WITH_PE */
|
||||
|
||||
/* The PE relocate section routine. The only difference between this
|
||||
and the regular routine is that we don't want to do anything for a
|
||||
relocatable link. */
|
||||
|
||||
static bfd_boolean coff_pe_i386_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
|
||||
static bfd_boolean
|
||||
coff_pe_i386_relocate_section (output_bfd, info, input_bfd,
|
||||
input_section, contents, relocs, syms,
|
||||
sections)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
if (info->relocatable)
|
||||
return TRUE;
|
||||
|
||||
return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
|
||||
input_section, contents,
|
||||
relocs, syms, sections);
|
||||
}
|
||||
|
||||
#define coff_relocate_section coff_pe_i386_relocate_section
|
||||
|
||||
#endif /* COFF_WITH_PE */
|
||||
|
||||
/* Convert an rtype to howto for the COFF backend linker. */
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
reloc_howto_type *howto;
|
||||
|
||||
if (rel->r_type > sizeof (howto_table) / sizeof (howto_table[0]))
|
||||
{
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
howto = howto_table + rel->r_type;
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
/* Cancel out code in _bfd_coff_generic_relocate_section. */
|
||||
*addendp = 0;
|
||||
#endif
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
|
||||
BFD_ASSERT (h != NULL);
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
/* I think we *do* want to bypass this. If we don't, I have
|
||||
seen some data parameters get the wrong relocation address.
|
||||
If I link two versions with and without this section bypassed
|
||||
and then do a binary comparison, the addresses which are
|
||||
different can be looked up in the map. The case in which
|
||||
this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map. */
|
||||
*addendp -= sym->n_value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocatable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
#endif
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
if (howto->pc_relative)
|
||||
{
|
||||
*addendp -= 4;
|
||||
|
||||
/* If the symbol is defined, then the generic code is going to
|
||||
add back the symbol value in order to cancel out an
|
||||
adjustment it made to the addend. However, we set the addend
|
||||
to 0 at the start of this function. We need to adjust here,
|
||||
to avoid the adjustment the generic code will make. FIXME:
|
||||
This is getting a bit hackish. */
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
if (rel->r_type == R_IMAGEBASE
|
||||
&& (bfd_get_flavour(sec->output_section->owner)
|
||||
== bfd_target_coff_flavour))
|
||||
{
|
||||
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
}
|
||||
|
||||
if (rel->r_type == R_SECREL32)
|
||||
{
|
||||
bfd_vma osect_vma;
|
||||
|
||||
if (h && (h->type == bfd_link_hash_defined
|
||||
|| h->type == bfd_link_hash_defweak))
|
||||
osect_vma = h->root.u.def.section->output_section->vma;
|
||||
else
|
||||
{
|
||||
asection *sec;
|
||||
int i;
|
||||
|
||||
/* Sigh, the only way to get the section to offset against
|
||||
is to find it the hard way. */
|
||||
|
||||
for (sec = abfd->sections, i = 1; i < sym->n_scnum; i++)
|
||||
sec = sec->next;
|
||||
|
||||
osect_vma = sec->output_section->vma;
|
||||
}
|
||||
|
||||
*addendp -= osect_vma;
|
||||
}
|
||||
#endif
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
#define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i386_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_RVA:
|
||||
return howto_table + R_IMAGEBASE;
|
||||
case BFD_RELOC_32:
|
||||
return howto_table + R_DIR32;
|
||||
case BFD_RELOC_32_PCREL:
|
||||
return howto_table + R_PCRLONG;
|
||||
case BFD_RELOC_16:
|
||||
return howto_table + R_RELWORD;
|
||||
case BFD_RELOC_16_PCREL:
|
||||
return howto_table + R_PCRWORD;
|
||||
case BFD_RELOC_8:
|
||||
return howto_table + R_RELBYTE;
|
||||
case BFD_RELOC_8_PCREL:
|
||||
return howto_table + R_PCRBYTE;
|
||||
#ifdef COFF_WITH_PE
|
||||
case BFD_RELOC_32_SECREL:
|
||||
return howto_table + R_SECREL32;
|
||||
#endif
|
||||
default:
|
||||
BFD_FAIL ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_i386_rtype_to_howto
|
||||
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
|
||||
/* If i386 gcc uses underscores for symbol names, then it does not use
|
||||
a leading dot for local labels, so if TARGET_UNDERSCORE is defined
|
||||
we treat all symbols starting with L as local. */
|
||||
|
||||
static bfd_boolean coff_i386_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
|
||||
static bfd_boolean
|
||||
coff_i386_is_local_label_name (abfd, name)
|
||||
bfd *abfd;
|
||||
const char *name;
|
||||
{
|
||||
if (name[0] == 'L')
|
||||
return TRUE;
|
||||
|
||||
return _bfd_coff_is_local_label_name (abfd, name);
|
||||
}
|
||||
|
||||
#define coff_bfd_is_local_label_name coff_i386_is_local_label_name
|
||||
|
||||
#endif /* TARGET_UNDERSCORE */
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
i386coff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-i386", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
|
||||
#ifdef COFF_WITH_PE
|
||||
| SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY
|
||||
#endif
|
||||
| SEC_CODE | SEC_DATA),
|
||||
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
712
bfd/coff-i860.c
712
bfd/coff-i860.c
@@ -1,712 +0,0 @@
|
||||
/* BFD back-end for Intel i860 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002,
|
||||
2003, 2004 Free Software Foundation, Inc.
|
||||
Created mostly by substituting "860" for "386" in coff-i386.c
|
||||
Harry Dolan <dolan@ssd.intel.com>, October 1995
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "coff/i860.h"
|
||||
|
||||
#include "coff/internal.h"
|
||||
|
||||
#include "libcoff.h"
|
||||
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* For some reason when using i860 COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. Ian Taylor, Cygnus Support. */
|
||||
|
||||
/* If we are producing relocatable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i860_reloc (bfd *abfd,
|
||||
arelent *reloc_entry,
|
||||
asymbol *symbol,
|
||||
void *data,
|
||||
asection *input_section ATTRIBUTE_UNUSED,
|
||||
bfd *output_bfd,
|
||||
char **error_message ATTRIBUTE_UNUSED)
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocatable output. This seems to be always wrong for 860
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* This is just a temporary measure until we teach bfd to generate
|
||||
these relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i860_reloc_nyi (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
arelent *reloc_entry,
|
||||
asymbol *symbol ATTRIBUTE_UNUSED,
|
||||
void *data ATTRIBUTE_UNUSED,
|
||||
asection *input_section ATTRIBUTE_UNUSED,
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
char **error_message ATTRIBUTE_UNUSED)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
fprintf (stderr, _("Relocation `%s' not yet implemented\n"), howto->name);
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET FALSE
|
||||
#endif
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
HOWTO (R_DIR32, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"dir32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
/* {7}, */
|
||||
HOWTO (R_IMAGEBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"rva32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
EMPTY_HOWTO (010),
|
||||
EMPTY_HOWTO (011),
|
||||
EMPTY_HOWTO (012),
|
||||
EMPTY_HOWTO (013),
|
||||
EMPTY_HOWTO (014),
|
||||
EMPTY_HOWTO (015),
|
||||
EMPTY_HOWTO (016),
|
||||
HOWTO (R_RELBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"8", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_RELWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"16", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_RELLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP8", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP16", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
EMPTY_HOWTO (0x15),
|
||||
EMPTY_HOWTO (0x16),
|
||||
EMPTY_HOWTO (0x17),
|
||||
EMPTY_HOWTO (0x18),
|
||||
EMPTY_HOWTO (0x19),
|
||||
EMPTY_HOWTO (0x1a),
|
||||
EMPTY_HOWTO (0x1b),
|
||||
HOWTO (COFF860_R_PAIR, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"PAIR", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
EMPTY_HOWTO (0x1d),
|
||||
HOWTO (COFF860_R_HIGH, /* type */
|
||||
16, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"HIGH", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW0, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW0", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW1, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW1", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xfffe, /* src_mask */
|
||||
0xfffe, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW2, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xfffc, /* src_mask */
|
||||
0xfffc, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW3, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW3", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xfff8, /* src_mask */
|
||||
0xfff8, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW4, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW4", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xfff0, /* src_mask */
|
||||
0xfff0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_SPLIT0, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"SPLIT0", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x1f07ff, /* src_mask */
|
||||
0x1f07ff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_SPLIT1, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"SPLIT1", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x1f07fe, /* src_mask */
|
||||
0x1f07fe, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_SPLIT2, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"SPLIT2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x1f07fc, /* src_mask */
|
||||
0x1f07fc, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_HIGHADJ, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"HIGHADJ", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_BRADDR, /* type */
|
||||
2, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
26, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"BRADDR", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x3ffffff, /* src_mask */
|
||||
0x3ffffff, /* dst_mask */
|
||||
TRUE) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc number. */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) I860BADMAG(x)
|
||||
#define I860 1 /* Customize coffcode.h */
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
((cache_ptr)->howto = \
|
||||
((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \
|
||||
? howto_table + (dst)->r_type \
|
||||
: NULL))
|
||||
|
||||
/* For 860 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
|
||||
library. On some other COFF targets STYP_BSS is normally
|
||||
STYP_NOLOAD. */
|
||||
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||
|
||||
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||
the object file contains the value of the common symbol. By the
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
/* FIXME: This was copied from the i386 version originally but
|
||||
appears to be wrong for i860. For now we'll do nothing. */
|
||||
#if 0
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && howto_table[reloc.r_type].pc_relative) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
#else
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr)
|
||||
#endif
|
||||
|
||||
/* We use the special COFF backend linker. */
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i860_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
asection *sec,
|
||||
struct internal_reloc *rel,
|
||||
struct coff_link_hash_entry *h,
|
||||
struct internal_syment *sym,
|
||||
bfd_vma *addendp)
|
||||
{
|
||||
|
||||
reloc_howto_type *howto;
|
||||
|
||||
if (rel->r_type > sizeof (howto_table) / sizeof (howto_table[0]))
|
||||
{
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
howto = howto_table + rel->r_type;
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
|
||||
BFD_ASSERT (h != NULL);
|
||||
|
||||
/* I think we *do* want to bypass this. If we don't, I have seen some data
|
||||
parameters get the wrong relocation address. If I link two versions
|
||||
with and without this section bypassed and then do a binary comparison,
|
||||
the addresses which are different can be looked up in the map. The
|
||||
case in which this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map. */
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocatable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i860_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
bfd_reloc_code_real_type code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_32:
|
||||
return howto_table + R_DIR32;
|
||||
case BFD_RELOC_860_PC26:
|
||||
return howto_table + COFF860_R_BRADDR;
|
||||
case BFD_RELOC_860_PC16:
|
||||
/* ??? How to handle PC16 for COFF? SPLIT0 is close for now. */
|
||||
return howto_table + COFF860_R_SPLIT0;
|
||||
case BFD_RELOC_860_LOW0:
|
||||
return howto_table + COFF860_R_LOW0;
|
||||
case BFD_RELOC_860_SPLIT0:
|
||||
return howto_table + COFF860_R_SPLIT0;
|
||||
case BFD_RELOC_860_LOW1:
|
||||
return howto_table + COFF860_R_LOW1;
|
||||
case BFD_RELOC_860_SPLIT1:
|
||||
return howto_table + COFF860_R_SPLIT1;
|
||||
case BFD_RELOC_860_LOW2:
|
||||
return howto_table + COFF860_R_LOW2;
|
||||
case BFD_RELOC_860_SPLIT2:
|
||||
return howto_table + COFF860_R_SPLIT2;
|
||||
case BFD_RELOC_860_LOW3:
|
||||
return howto_table + COFF860_R_LOW3;
|
||||
case BFD_RELOC_860_HIGHADJ:
|
||||
return howto_table + COFF860_R_HIGHADJ;
|
||||
case BFD_RELOC_860_HIGH:
|
||||
return howto_table + COFF860_R_HIGH;
|
||||
default:
|
||||
BFD_FAIL ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is called from coff_slurp_reloc_table for each relocation
|
||||
entry. This special handling is due to the `PAIR' relocation
|
||||
which has a different meaning for the `r_symndx' field. */
|
||||
|
||||
static void
|
||||
i860_reloc_processing (arelent *cache_ptr, struct internal_reloc *dst,
|
||||
asymbol **symbols, bfd *abfd, asection *asect)
|
||||
{
|
||||
if (dst->r_type == COFF860_R_PAIR)
|
||||
{
|
||||
/* Handle the PAIR relocation specially. */
|
||||
cache_ptr->howto = howto_table + dst->r_type;
|
||||
cache_ptr->address = dst->r_vaddr;
|
||||
cache_ptr->addend = dst->r_symndx;
|
||||
cache_ptr->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For every other relocation, do exactly what coff_slurp_reloc_table
|
||||
would do (which this code is taken directly from). */
|
||||
asymbol *ptr = NULL;
|
||||
cache_ptr->address = dst->r_vaddr;
|
||||
|
||||
if (dst->r_symndx != -1)
|
||||
{
|
||||
if (dst->r_symndx < 0 || dst->r_symndx >= obj_conv_table_size (abfd))
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: warning: illegal symbol index %ld in relocs"),
|
||||
abfd, dst->r_symndx);
|
||||
cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache_ptr->sym_ptr_ptr = (symbols
|
||||
+ obj_convert (abfd)[dst->r_symndx]);
|
||||
ptr = *(cache_ptr->sym_ptr_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
|
||||
/* The symbols definitions that we have read in have been
|
||||
relocated as if their sections started at 0. But the offsets
|
||||
refering to the symbols in the raw data have not been
|
||||
modified, so we have to have a negative addend to compensate.
|
||||
|
||||
Note that symbols which used to be common must be left alone. */
|
||||
|
||||
/* Calculate any reloc addend by looking at the symbol. */
|
||||
CALC_ADDEND (abfd, ptr, (*dst), cache_ptr);
|
||||
|
||||
cache_ptr->address -= asect->vma;
|
||||
|
||||
/* Fill in the cache_ptr->howto field from dst->r_type. */
|
||||
RTYPE2HOWTO (cache_ptr, dst);
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_i860_rtype_to_howto
|
||||
#define coff_bfd_reloc_type_lookup coff_i860_reloc_type_lookup
|
||||
|
||||
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
|
||||
i860_reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static const bfd_target *
|
||||
i3coff_object_p(bfd *a)
|
||||
{
|
||||
return coff_object_p (a);
|
||||
}
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
i860coff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-i860", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, i3coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
665
bfd/coff-i960.c
665
bfd/coff-i960.c
@@ -1,665 +0,0 @@
|
||||
/* BFD back-end for Intel 960 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001,
|
||||
2002, 2003 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define I960 1
|
||||
#define BADMAG(x) I960BADMAG(x)
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/i960.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h" /* to allow easier abstraction-breaking */
|
||||
|
||||
static bfd_boolean coff_i960_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
static bfd_reloc_status_type optcall_callback
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type coff_i960_relocate
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_i960_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static bfd_boolean coff_i960_start_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static bfd_boolean coff_i960_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static bfd_boolean coff_i960_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, bfd_boolean *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
#define COFF_ALIGN_IN_SECTION_HEADER 1
|
||||
|
||||
#define GET_SCNHDR_ALIGN H_GET_32
|
||||
#define PUT_SCNHDR_ALIGN H_PUT_32
|
||||
|
||||
/* The i960 does not support an MMU, so COFF_PAGE_SIZE can be
|
||||
arbitrarily small. */
|
||||
#define COFF_PAGE_SIZE 1
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
/* This set of local label names is taken from gas. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_i960_is_local_label_name (abfd, name)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
const char *name;
|
||||
{
|
||||
return (name[0] == 'L'
|
||||
|| (name[0] == '.'
|
||||
&& (name[1] == 'C'
|
||||
|| name[1] == 'I'
|
||||
|| name[1] == '.')));
|
||||
}
|
||||
|
||||
/* This is just like the usual CALC_ADDEND, but it includes the
|
||||
section VMA for PC relative relocs. */
|
||||
#ifndef CALC_ADDEND
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = 0; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == 25 || reloc.r_type == 27)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CALLS 0x66003800 /* Template for 'calls' instruction */
|
||||
#define BAL 0x0b000000 /* Template for 'bal' instruction */
|
||||
#define BAL_MASK 0x00ffffff
|
||||
|
||||
static bfd_reloc_status_type
|
||||
optcall_callback (abfd, reloc_entry, symbol_in, data,
|
||||
input_section, ignore_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol_in;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *ignore_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message;
|
||||
{
|
||||
/* This item has already been relocated correctly, but we may be
|
||||
* able to patch in yet better code - done by digging out the
|
||||
* correct info on this symbol */
|
||||
bfd_reloc_status_type result;
|
||||
coff_symbol_type *cs = coffsymbol(symbol_in);
|
||||
|
||||
/* Don't do anything with symbols which aren't tied up yet,
|
||||
except move the reloc. */
|
||||
if (bfd_is_und_section (cs->symbol.section)) {
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
/* So the target symbol has to be of coff type, and the symbol
|
||||
has to have the correct native information within it */
|
||||
if ((bfd_asymbol_flavour(&cs->symbol) != bfd_target_coff_flavour)
|
||||
|| (cs->native == (combined_entry_type *)NULL))
|
||||
{
|
||||
/* This is interesting, consider the case where we're outputting coff
|
||||
from a mix n match input, linking from coff to a symbol defined in a
|
||||
bout file will cause this match to be true. Should I complain? This
|
||||
will only work if the bout symbol is non leaf. */
|
||||
*error_message =
|
||||
(char *) _("uncertain calling convention for non-COFF symbol");
|
||||
result = bfd_reloc_dangerous;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (cs->native->u.syment.n_sclass)
|
||||
{
|
||||
case C_LEAFSTAT:
|
||||
case C_LEAFEXT:
|
||||
/* This is a call to a leaf procedure, replace instruction with a bal
|
||||
to the correct location. */
|
||||
{
|
||||
union internal_auxent *aux = &((cs->native+2)->u.auxent);
|
||||
int word = bfd_get_32 (abfd, (bfd_byte *)data + reloc_entry->address);
|
||||
int olf = (aux->x_bal.x_balntry - cs->native->u.syment.n_value);
|
||||
BFD_ASSERT(cs->native->u.syment.n_numaux==2);
|
||||
|
||||
/* We replace the original call instruction with a bal to
|
||||
the bal entry point - the offset of which is described in
|
||||
the 2nd auxent of the original symbol. We keep the native
|
||||
sym and auxents untouched, so the delta between the two
|
||||
is the offset of the bal entry point. */
|
||||
word = ((word + olf) & BAL_MASK) | BAL;
|
||||
bfd_put_32 (abfd, (bfd_vma) word,
|
||||
(bfd_byte *) data + reloc_entry->address);
|
||||
}
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
case C_SCALL:
|
||||
/* This is a call to a system call, replace with a calls to # */
|
||||
BFD_ASSERT(0);
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
default:
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
|
||||
appear to correctly handle a reloc against a symbol defined in the
|
||||
same object file. It appears to simply discard such relocs, rather
|
||||
than adding their values into the object file. We handle this here
|
||||
by converting all relocs against defined symbols into relocs
|
||||
against the section symbol, when generating a relocatable output
|
||||
file.
|
||||
|
||||
Note that this function is only called if we are not using the COFF
|
||||
specific backend linker. It only does something when doing a
|
||||
relocatable link, which will almost certainly fail when not
|
||||
generating COFF i960 output, so this function is actually no longer
|
||||
useful. It was used before this target was converted to use the
|
||||
COFF specific backend linker. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
asection *osec;
|
||||
|
||||
if (output_bfd == NULL)
|
||||
{
|
||||
/* Not generating relocatable output file. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
if (bfd_is_und_section (bfd_get_section (symbol)))
|
||||
{
|
||||
/* Symbol is not defined, so no need to worry about it. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
if (bfd_is_com_section (bfd_get_section (symbol)))
|
||||
{
|
||||
/* I don't really know what the right action is for a common
|
||||
symbol. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* Convert the reloc to use the section symbol. FIXME: This method
|
||||
is ridiculous. */
|
||||
osec = bfd_get_section (symbol)->output_section;
|
||||
if (coff_section_data (output_bfd, osec) != NULL
|
||||
&& coff_section_data (output_bfd, osec)->tdata != NULL)
|
||||
reloc_entry->sym_ptr_ptr =
|
||||
(asymbol **) coff_section_data (output_bfd, osec)->tdata;
|
||||
else
|
||||
{
|
||||
const char *sec_name;
|
||||
asymbol **syms, **sym_end;
|
||||
|
||||
sec_name = bfd_get_section_name (output_bfd, osec);
|
||||
syms = bfd_get_outsymbols (output_bfd);
|
||||
sym_end = syms + bfd_get_symcount (output_bfd);
|
||||
for (; syms < sym_end; syms++)
|
||||
{
|
||||
if (bfd_asymbol_name (*syms) != NULL
|
||||
&& (*syms)->value == 0
|
||||
&& strcmp ((*syms)->section->output_section->name,
|
||||
sec_name) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (syms >= sym_end)
|
||||
abort ();
|
||||
|
||||
reloc_entry->sym_ptr_ptr = syms;
|
||||
|
||||
if (coff_section_data (output_bfd, osec) == NULL)
|
||||
{
|
||||
bfd_size_type amt = sizeof (struct coff_section_tdata);
|
||||
osec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
|
||||
if (osec->used_by_bfd == NULL)
|
||||
return bfd_reloc_overflow;
|
||||
}
|
||||
coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
|
||||
}
|
||||
|
||||
/* Let bfd_perform_relocation do its thing, which will include
|
||||
stuffing the symbol addend into the object file. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_rellong =
|
||||
HOWTO ((unsigned int) R_RELLONG, 0, 2, 32,FALSE, 0,
|
||||
complain_overflow_bitfield, coff_i960_relocate,"rellong", TRUE,
|
||||
0xffffffff, 0xffffffff, 0);
|
||||
static reloc_howto_type howto_iprmed =
|
||||
HOWTO (R_IPRMED, 0, 2, 24,TRUE,0, complain_overflow_signed,
|
||||
coff_i960_relocate, "iprmed ", TRUE, 0x00ffffff, 0x00ffffff, 0);
|
||||
static reloc_howto_type howto_optcall =
|
||||
HOWTO (R_OPTCALL, 0,2,24,TRUE,0, complain_overflow_signed,
|
||||
optcall_callback, "optcall", TRUE, 0x00ffffff, 0x00ffffff, 0);
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i960_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case BFD_RELOC_I960_CALLJ:
|
||||
return &howto_optcall;
|
||||
case BFD_RELOC_32:
|
||||
case BFD_RELOC_CTOR:
|
||||
return &howto_rellong;
|
||||
case BFD_RELOC_24_PCREL:
|
||||
return &howto_iprmed;
|
||||
}
|
||||
}
|
||||
|
||||
/* The real code is in coffcode.h */
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
{ \
|
||||
reloc_howto_type *howto_ptr; \
|
||||
switch ((dst)->r_type) { \
|
||||
case 17: howto_ptr = &howto_rellong; break; \
|
||||
case 25: howto_ptr = &howto_iprmed; break; \
|
||||
case 27: howto_ptr = &howto_optcall; break; \
|
||||
default: howto_ptr = 0; break; \
|
||||
} \
|
||||
(cache_ptr)->howto = howto_ptr; \
|
||||
}
|
||||
|
||||
/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
|
||||
appear to correctly handle a reloc against a symbol defined in the
|
||||
same object file. It appears to simply discard such relocs, rather
|
||||
than adding their values into the object file. We handle this by
|
||||
converting all relocs against global symbols into relocs against
|
||||
internal symbols at the start of the section. This routine is
|
||||
called at the start of the linking process, and it creates the
|
||||
necessary symbols. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_i960_start_final_link (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
bfd_size_type symesz = bfd_coff_symesz (abfd);
|
||||
asection *o;
|
||||
bfd_byte *esym;
|
||||
|
||||
if (! info->relocatable)
|
||||
return TRUE;
|
||||
|
||||
esym = (bfd_byte *) bfd_malloc (symesz);
|
||||
if (esym == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
|
||||
return FALSE;
|
||||
|
||||
for (o = abfd->sections; o != NULL; o = o->next)
|
||||
{
|
||||
struct internal_syment isym;
|
||||
|
||||
strncpy (isym._n._n_name, o->name, SYMNMLEN);
|
||||
isym.n_value = 0;
|
||||
isym.n_scnum = o->target_index;
|
||||
isym.n_type = T_NULL;
|
||||
isym.n_sclass = C_STAT;
|
||||
isym.n_numaux = 0;
|
||||
|
||||
bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
|
||||
|
||||
if (bfd_bwrite (esym, symesz, abfd) != symesz)
|
||||
{
|
||||
free (esym);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
obj_raw_syment_count (abfd) += 1;
|
||||
}
|
||||
|
||||
free (esym);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_i960_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
struct internal_reloc *rel;
|
||||
struct internal_reloc *relend;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma addend;
|
||||
bfd_vma val;
|
||||
reloc_howto_type *howto;
|
||||
bfd_reloc_status_type rstat = bfd_reloc_ok;
|
||||
bfd_boolean done;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
h = NULL;
|
||||
sym = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
sym = syms + symndx;
|
||||
}
|
||||
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
addend = - sym->n_value;
|
||||
else
|
||||
addend = 0;
|
||||
|
||||
switch (rel->r_type)
|
||||
{
|
||||
case 17: howto = &howto_rellong; break;
|
||||
case 25: howto = &howto_iprmed; break;
|
||||
case 27: howto = &howto_optcall; break;
|
||||
default:
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
val = 0;
|
||||
|
||||
if (h == NULL)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
sec = bfd_abs_section_ptr;
|
||||
val = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value
|
||||
- sec->vma);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else if (! info->relocatable)
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma, TRUE)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
done = FALSE;
|
||||
|
||||
if (howto->type == R_OPTCALL && ! info->relocatable && symndx != -1)
|
||||
{
|
||||
int class;
|
||||
|
||||
if (h != NULL)
|
||||
class = h->class;
|
||||
else
|
||||
class = sym->n_sclass;
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case C_NULL:
|
||||
/* This symbol is apparently not from a COFF input file.
|
||||
We warn, and then assume that it is not a leaf
|
||||
function. */
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info,
|
||||
_("uncertain calling convention for non-COFF symbol"),
|
||||
input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
break;
|
||||
case C_LEAFSTAT:
|
||||
case C_LEAFEXT:
|
||||
/* This is a call to a leaf procedure; use the bal
|
||||
instruction. */
|
||||
{
|
||||
long olf;
|
||||
unsigned long word;
|
||||
|
||||
if (h != NULL)
|
||||
{
|
||||
BFD_ASSERT (h->numaux == 2);
|
||||
olf = h->aux[1].x_bal.x_balntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_byte *esyms;
|
||||
union internal_auxent aux;
|
||||
|
||||
BFD_ASSERT (sym->n_numaux == 2);
|
||||
esyms = (bfd_byte *) obj_coff_external_syms (input_bfd);
|
||||
esyms += (symndx + 2) * bfd_coff_symesz (input_bfd);
|
||||
bfd_coff_swap_aux_in (input_bfd, (PTR) esyms, sym->n_type,
|
||||
sym->n_sclass, 1, sym->n_numaux,
|
||||
(PTR) &aux);
|
||||
olf = aux.x_bal.x_balntry;
|
||||
}
|
||||
|
||||
word = bfd_get_32 (input_bfd,
|
||||
(contents
|
||||
+ (rel->r_vaddr - input_section->vma)));
|
||||
word = ((word + olf - val) & BAL_MASK) | BAL;
|
||||
bfd_put_32 (input_bfd,
|
||||
(bfd_vma) word,
|
||||
contents + (rel->r_vaddr - input_section->vma));
|
||||
done = TRUE;
|
||||
}
|
||||
break;
|
||||
case C_SCALL:
|
||||
BFD_ASSERT (0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! done)
|
||||
{
|
||||
if (howto->pc_relative)
|
||||
addend += input_section->vma;
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents,
|
||||
rel->r_vaddr - input_section->vma,
|
||||
val, addend);
|
||||
}
|
||||
|
||||
switch (rstat)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
case bfd_reloc_ok:
|
||||
break;
|
||||
case bfd_reloc_overflow:
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
|
||||
if (name == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto->name, (bfd_vma) 0, input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Adjust the symbol index of any reloc against a global symbol to
|
||||
instead be a reloc against the internal symbol we created specially
|
||||
for the section. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
||||
bfd *ibfd;
|
||||
asection *sec ATTRIBUTE_UNUSED;
|
||||
struct internal_reloc *irel;
|
||||
bfd_boolean *adjustedp;
|
||||
{
|
||||
struct coff_link_hash_entry *h;
|
||||
|
||||
*adjustedp = FALSE;
|
||||
|
||||
h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
|
||||
if (h == NULL
|
||||
|| (h->root.type != bfd_link_hash_defined
|
||||
&& h->root.type != bfd_link_hash_defweak))
|
||||
return TRUE;
|
||||
|
||||
irel->r_symndx = h->root.u.def.section->output_section->target_index - 1;
|
||||
*adjustedp = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define coff_bfd_is_local_label_name coff_i960_is_local_label_name
|
||||
|
||||
#define coff_start_final_link coff_i960_start_final_link
|
||||
|
||||
#define coff_relocate_section coff_i960_relocate_section
|
||||
|
||||
#define coff_adjust_symndx coff_i960_adjust_symndx
|
||||
|
||||
#define coff_bfd_reloc_type_lookup coff_i960_reloc_type_lookup
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
extern const bfd_target icoff_big_vec;
|
||||
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (icoff_little_vec, "coff-Intel-little", 0, 0, '_', & icoff_big_vec, COFF_SWAP_TABLE)
|
||||
|
||||
const bfd_target icoff_big_vec =
|
||||
{
|
||||
"coff-Intel-big", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& icoff_little_vec,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
202
bfd/coff-ia64.c
202
bfd/coff-ia64.c
@@ -1,202 +0,0 @@
|
||||
/* BFD back-end for HP/Intel IA-64 COFF files.
|
||||
Copyright 1999, 2000, 2001, 2002 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/ia64.h"
|
||||
#include "coff/internal.h"
|
||||
#include "coff/pe.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
};
|
||||
|
||||
#define BADMAG(x) IA64BADMAG(x)
|
||||
#define IA64 1 /* Customize coffcode.h */
|
||||
|
||||
#ifdef COFF_WITH_pep
|
||||
# undef AOUTSZ
|
||||
# define AOUTSZ PEPAOUTSZ
|
||||
# define PEAOUTHDR PEPAOUTHDR
|
||||
#endif
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
/* Return TRUE if this relocation should
|
||||
appear in the output .reloc section. */
|
||||
|
||||
static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
|
||||
|
||||
static bfd_boolean
|
||||
in_reloc_p(abfd, howto)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
reloc_howto_type *howto ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return FALSE; /* We don't do relocs for now... */
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static const bfd_target *ia64coff_object_p PARAMS ((bfd *));
|
||||
|
||||
static const bfd_target *
|
||||
ia64coff_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
#ifdef COFF_IMAGE_WITH_PE
|
||||
{
|
||||
struct external_PEI_DOS_hdr dos_hdr;
|
||||
struct external_PEI_IMAGE_hdr image_hdr;
|
||||
file_ptr offset;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||
|| (bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd)
|
||||
!= sizeof (dos_hdr)))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* There are really two magic numbers involved; the magic number
|
||||
that says this is a NT executable (PEI) and the magic number
|
||||
that determines the architecture. The former is DOSMAGIC,
|
||||
stored in the e_magic field. The latter is stored in the
|
||||
f_magic field. If the NT magic number isn't valid, the
|
||||
architecture magic number could be mimicked by some other
|
||||
field (specifically, the number of relocs in section 3). Since
|
||||
this routine can only be called correctly for a PEI file, check
|
||||
the e_magic number here, and, if it doesn't match, clobber the
|
||||
f_magic number so that we don't get a false match. */
|
||||
if (H_GET_16 (abfd, dos_hdr.e_magic) != DOSMAGIC)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
offset = H_GET_32 (abfd, dos_hdr.e_lfanew);
|
||||
if (bfd_seek (abfd, offset, SEEK_SET) != 0
|
||||
|| (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd)
|
||||
!= sizeof (image_hdr)))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (H_GET_32 (abfd, image_hdr.nt_signature)
|
||||
!= 0x4550)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Here is the hack. coff_object_p wants to read filhsz bytes to
|
||||
pick up the COFF header for PE, see "struct external_PEI_filehdr"
|
||||
in include/coff/pe.h. We adjust so that that will work. */
|
||||
if (bfd_seek (abfd, offset - sizeof (dos_hdr), SEEK_SET) != 0)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return coff_object_p (abfd);
|
||||
}
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
ia64coff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-ia64", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
|
||||
| SEC_CODE | SEC_DATA),
|
||||
#else
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
|
||||
| SEC_CODE | SEC_DATA
|
||||
| SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, ia64coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, ia64coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
538
bfd/coff-m68k.c
538
bfd/coff-m68k.c
@@ -1,538 +0,0 @@
|
||||
/* BFD back-end for Motorola 68000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999,
|
||||
2000, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/m68k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
/* This source file is compiled multiple times for various m68k COFF
|
||||
variants. The following macros control its behaviour:
|
||||
|
||||
TARGET_SYM
|
||||
The C name of the BFD target vector. The default is m68kcoff_vec.
|
||||
TARGET_NAME
|
||||
The user visible target name. The default is "coff-m68k".
|
||||
NAMES_HAVE_UNDERSCORE
|
||||
Whether symbol names have an underscore.
|
||||
ONLY_DECLARE_RELOCS
|
||||
Only declare the relocation howto array. Don't actually compile
|
||||
it. The actual array will be picked up in another version of the
|
||||
file.
|
||||
STATIC_RELOCS
|
||||
Make the relocation howto array, and associated functions, static.
|
||||
COFF_COMMON_ADDEND
|
||||
If this is defined, then, for a relocation against a common
|
||||
symbol, the object file holds the value (the size) of the common
|
||||
symbol. If this is not defined, then, for a relocation against a
|
||||
common symbol, the object file holds zero. */
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
#ifndef COFF_PAGE_SIZE
|
||||
/* The page size is a guess based on ELF. */
|
||||
#define COFF_PAGE_SIZE 0x2000
|
||||
#endif
|
||||
|
||||
#ifndef COFF_COMMON_ADDEND
|
||||
#define RELOC_SPECIAL_FN 0
|
||||
#else
|
||||
static bfd_reloc_status_type m68kcoff_common_addend_special_fn
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *m68kcoff_common_addend_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
#define RELOC_SPECIAL_FN m68kcoff_common_addend_special_fn
|
||||
#endif
|
||||
|
||||
static bfd_boolean m68k_coff_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
|
||||
/* On the delta, a symbol starting with L% is local. We won't see
|
||||
such a symbol on other platforms, so it should be safe to always
|
||||
consider it local here. */
|
||||
|
||||
static bfd_boolean
|
||||
m68k_coff_is_local_label_name (abfd, name)
|
||||
bfd *abfd;
|
||||
const char *name;
|
||||
{
|
||||
if (name[0] == 'L' && name[1] == '%')
|
||||
return TRUE;
|
||||
|
||||
return _bfd_coff_is_local_label_name (abfd, name);
|
||||
}
|
||||
|
||||
#ifndef STATIC_RELOCS
|
||||
/* Clean up namespace. */
|
||||
#define m68kcoff_howto_table _bfd_m68kcoff_howto_table
|
||||
#define m68k_rtype2howto _bfd_m68kcoff_rtype2howto
|
||||
#define m68k_howto2rtype _bfd_m68kcoff_howto2rtype
|
||||
#define m68k_reloc_type_lookup _bfd_m68kcoff_reloc_type_lookup
|
||||
#endif
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern reloc_howto_type m68kcoff_howto_table[];
|
||||
#else
|
||||
#ifdef STATIC_RELOCS
|
||||
static
|
||||
#endif
|
||||
reloc_howto_type m68kcoff_howto_table[] =
|
||||
{
|
||||
HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
HOWTO (R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
HOWTO (R_RELLONG_NEG, 0, -2, 32, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "-32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
};
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#ifndef BADMAG
|
||||
#define BADMAG(x) M68KBADMAG(x)
|
||||
#endif
|
||||
#define M68 1 /* Customize coffcode.h */
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
|
||||
extern int m68k_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
extern reloc_howto_type *m68k_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
#else
|
||||
|
||||
#ifdef STATIC_RELOCS
|
||||
#define STAT_REL static
|
||||
#else
|
||||
#define STAT_REL
|
||||
#endif
|
||||
|
||||
STAT_REL reloc_howto_type * m68k_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
STAT_REL int m68k_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
STAT_REL void m68k_rtype2howto PARAMS ((arelent *, int));
|
||||
|
||||
|
||||
STAT_REL void
|
||||
m68k_rtype2howto(internal, relocentry)
|
||||
arelent *internal;
|
||||
int relocentry;
|
||||
{
|
||||
switch (relocentry)
|
||||
{
|
||||
case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break;
|
||||
case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break;
|
||||
case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break;
|
||||
case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break;
|
||||
case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break;
|
||||
case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break;
|
||||
case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break;
|
||||
}
|
||||
}
|
||||
|
||||
STAT_REL int
|
||||
m68k_howto2rtype (internal)
|
||||
reloc_howto_type *internal;
|
||||
{
|
||||
if (internal->pc_relative)
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_PCRLONG;
|
||||
case 16: return R_PCRWORD;
|
||||
case 8: return R_PCRBYTE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_RELLONG;
|
||||
case 16: return R_RELWORD;
|
||||
case 8: return R_RELBYTE;
|
||||
}
|
||||
}
|
||||
return R_RELLONG;
|
||||
}
|
||||
|
||||
STAT_REL reloc_howto_type *
|
||||
m68k_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
default: return NULL;
|
||||
case BFD_RELOC_8: return m68kcoff_howto_table + 0;
|
||||
case BFD_RELOC_16: return m68kcoff_howto_table + 1;
|
||||
case BFD_RELOC_CTOR:
|
||||
case BFD_RELOC_32: return m68kcoff_howto_table + 2;
|
||||
case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3;
|
||||
case BFD_RELOC_16_PCREL: return m68kcoff_howto_table + 4;
|
||||
case BFD_RELOC_32_PCREL: return m68kcoff_howto_table + 5;
|
||||
/* FIXME: There doesn't seem to be a code for R_RELLONG_NEG. */
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) \
|
||||
m68k_rtype2howto(internal, (relocentry)->r_type)
|
||||
|
||||
#define SELECT_RELOC(external, internal) \
|
||||
external.r_type = m68k_howto2rtype (internal)
|
||||
|
||||
#define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup
|
||||
|
||||
#ifndef COFF_COMMON_ADDEND
|
||||
#ifndef coff_rtype_to_howto
|
||||
|
||||
#define coff_rtype_to_howto m68kcoff_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *m68kcoff_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
static reloc_howto_type *
|
||||
m68kcoff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment *sym ATTRIBUTE_UNUSED;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
#endif /* ! defined (coff_rtype_to_howto) */
|
||||
#endif /* ! defined (COFF_COMMON_ADDEND) */
|
||||
|
||||
#ifdef COFF_COMMON_ADDEND
|
||||
|
||||
/* If COFF_COMMON_ADDEND is defined, then when using m68k COFF the
|
||||
value stored in the .text section for a reference to a common
|
||||
symbol is the value itself plus any desired offset. (taken from
|
||||
work done by Ian Taylor, Cygnus Support, for I386 COFF). */
|
||||
|
||||
/* If we are producing relocatable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
m68kcoff_common_addend_special_fn (abfd, reloc_entry, symbol, data,
|
||||
input_section, output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocatable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||
the object file contains the value of the common symbol. By the
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == R_PCRBYTE \
|
||||
|| reloc.r_type == R_PCRWORD \
|
||||
|| reloc.r_type == R_PCRLONG)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
#ifndef coff_rtype_to_howto
|
||||
|
||||
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||
adjust common symbols. */
|
||||
|
||||
static reloc_howto_type *
|
||||
m68kcoff_common_addend_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
BFD_ASSERT (h != NULL);
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocatable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto m68kcoff_common_addend_rtype_to_howto
|
||||
|
||||
#endif /* ! defined (coff_rtype_to_howto) */
|
||||
|
||||
#endif /* COFF_COMMON_ADDEND */
|
||||
|
||||
#if !defined ONLY_DECLARE_RELOCS && ! defined STATIC_RELOCS
|
||||
/* Given a .data section and a .emreloc in-memory section, store
|
||||
relocation information into the .emreloc section which can be
|
||||
used at runtime to relocate the section. This is called by the
|
||||
linker when the --embedded-relocs switch is used. This is called
|
||||
after the add_symbols entry point has been called for all the
|
||||
objects, and before the final_link entry point is called. */
|
||||
|
||||
bfd_boolean
|
||||
bfd_m68k_coff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
asection *datasec;
|
||||
asection *relsec;
|
||||
char **errmsg;
|
||||
{
|
||||
char *extsyms;
|
||||
bfd_size_type symesz;
|
||||
struct internal_reloc *irel, *irelend;
|
||||
bfd_byte *p;
|
||||
bfd_size_type amt;
|
||||
|
||||
BFD_ASSERT (! info->relocatable);
|
||||
|
||||
*errmsg = NULL;
|
||||
|
||||
if (datasec->reloc_count == 0)
|
||||
return TRUE;
|
||||
|
||||
extsyms = obj_coff_external_syms (abfd);
|
||||
symesz = bfd_coff_symesz (abfd);
|
||||
|
||||
irel = _bfd_coff_read_internal_relocs (abfd, datasec, TRUE, NULL, FALSE,
|
||||
NULL);
|
||||
irelend = irel + datasec->reloc_count;
|
||||
|
||||
amt = (bfd_size_type) datasec->reloc_count * 12;
|
||||
relsec->contents = (bfd_byte *) bfd_alloc (abfd, amt);
|
||||
if (relsec->contents == NULL)
|
||||
return FALSE;
|
||||
|
||||
p = relsec->contents;
|
||||
|
||||
for (; irel < irelend; irel++, p += 12)
|
||||
{
|
||||
asection *targetsec;
|
||||
|
||||
/* We are going to write a four byte longword into the runtime
|
||||
reloc section. The longword will be the address in the data
|
||||
section which must be relocated. It is followed by the name
|
||||
of the target section NUL-padded or truncated to 8
|
||||
characters. */
|
||||
|
||||
/* We can only relocate absolute longword relocs at run time. */
|
||||
if (irel->r_type != R_RELLONG)
|
||||
{
|
||||
*errmsg = _("unsupported reloc type");
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (irel->r_symndx == -1)
|
||||
targetsec = bfd_abs_section_ptr;
|
||||
else
|
||||
{
|
||||
struct coff_link_hash_entry *h;
|
||||
|
||||
h = obj_coff_sym_hashes (abfd)[irel->r_symndx];
|
||||
if (h == NULL)
|
||||
{
|
||||
struct internal_syment isym;
|
||||
|
||||
bfd_coff_swap_sym_in (abfd, extsyms + symesz * irel->r_symndx,
|
||||
&isym);
|
||||
targetsec = coff_section_from_bfd_index (abfd, isym.n_scnum);
|
||||
}
|
||||
else if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
targetsec = h->root.u.def.section;
|
||||
else
|
||||
targetsec = NULL;
|
||||
}
|
||||
|
||||
bfd_put_32 (abfd,
|
||||
(irel->r_vaddr - datasec->vma + datasec->output_offset), p);
|
||||
memset (p + 4, 0, 8);
|
||||
if (targetsec != NULL)
|
||||
strncpy (p + 4, targetsec->output_section->name, 8);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* neither ONLY_DECLARE_RELOCS not STATIC_RELOCS */
|
||||
|
||||
#define coff_bfd_is_local_label_name m68k_coff_is_local_label_name
|
||||
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifndef TARGET_SYM
|
||||
#define TARGET_SYM m68kcoff_vec
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_NAME
|
||||
#define TARGET_NAME "coff-m68k"
|
||||
#endif
|
||||
|
||||
#ifdef NAMES_HAVE_UNDERSCORE
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
#else
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, 0, NULL, COFF_SWAP_TABLE)
|
||||
#endif
|
||||
291
bfd/coff-m88k.c
291
bfd/coff-m88k.c
@@ -1,291 +0,0 @@
|
||||
/* BFD back-end for Motorola 88000 COFF "Binary Compatibility Standard" files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define M88 1 /* Customize various include files */
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/m88k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_boolean m88k_is_local_label_name PARAMS ((bfd *, const char *));
|
||||
static bfd_reloc_status_type m88k_special_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
#define GET_SCNHDR_NRELOC H_GET_32
|
||||
#define GET_SCNHDR_NLNNO H_GET_32
|
||||
|
||||
/* On coff-m88k, local labels start with '@'. */
|
||||
|
||||
#define coff_bfd_is_local_label_name m88k_is_local_label_name
|
||||
|
||||
static bfd_boolean
|
||||
m88k_is_local_label_name (abfd, name)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
const char *name;
|
||||
{
|
||||
return name[0] == '@';
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
m88k_special_reloc (abfd, reloc_entry, symbol, data,
|
||||
input_section, output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
|
||||
switch (howto->type)
|
||||
{
|
||||
case R_HVRT16:
|
||||
case R_LVRT16:
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the
|
||||
relocation to the reloc entry rather than the raw data.
|
||||
Modify the reloc inplace to reflect what we now know. */
|
||||
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_vma output_base = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
bfd_vma x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
|
||||
asection *reloc_target_output_section;
|
||||
long relocation = 0;
|
||||
|
||||
/* Work out which section the relocation is targeted at and the
|
||||
initial relocation command value. */
|
||||
|
||||
/* Get symbol value. (Common symbols are special.) */
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
relocation = 0;
|
||||
else
|
||||
relocation = symbol->value;
|
||||
|
||||
reloc_target_output_section = symbol->section->output_section;
|
||||
|
||||
/* Convert input-section-relative symbol value to absolute. */
|
||||
if (output_bfd)
|
||||
output_base = 0;
|
||||
else
|
||||
output_base = reloc_target_output_section->vma;
|
||||
|
||||
relocation += output_base + symbol->section->output_offset;
|
||||
|
||||
/* Add in supplied addend. */
|
||||
relocation += ((reloc_entry->addend << howto->bitsize) + x);
|
||||
|
||||
reloc_entry->addend = 0;
|
||||
|
||||
relocation >>= (bfd_vma) howto->rightshift;
|
||||
|
||||
/* Shift everything up to where it's going to be used */
|
||||
|
||||
relocation <<= (bfd_vma) howto->bitpos;
|
||||
|
||||
if (relocation)
|
||||
bfd_put_16 (abfd, (bfd_vma) relocation,
|
||||
(unsigned char *) data + addr);
|
||||
}
|
||||
|
||||
/* If we are not producing relocatable output, return an error if
|
||||
the symbol is not defined. */
|
||||
if (bfd_is_und_section (symbol->section) && output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_undefined;
|
||||
|
||||
return bfd_reloc_ok;
|
||||
|
||||
default:
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the
|
||||
relocation to the reloc entry rather than the raw data.
|
||||
Modify the reloc inplace to reflect what we now know. */
|
||||
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
HOWTO (R_PCR16L, /* type */
|
||||
02, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"PCR16L", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PCR26L, /* type */
|
||||
02, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
26, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"PCR26L", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x03ffffff, /* src_mask */
|
||||
0x03ffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_VRT16, /* type */
|
||||
00, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"VRT16", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_HVRT16, /* type */
|
||||
16, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"HVRT16", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LVRT16, /* type */
|
||||
00, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"LVRT16", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_VRT32, /* type */
|
||||
00, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"VRT32", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Code to turn an external r_type into a pointer to an entry in the
|
||||
above howto table. */
|
||||
static void
|
||||
rtype2howto (cache_ptr, dst)
|
||||
arelent *cache_ptr;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
if (dst->r_type >= R_PCR16L && dst->r_type <= R_VRT32)
|
||||
{
|
||||
cache_ptr->howto = howto_table + dst->r_type - R_PCR16L;
|
||||
}
|
||||
else
|
||||
{
|
||||
BFD_ASSERT (0);
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
|
||||
|
||||
/* Code to swap in the reloc offset */
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_16
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_16
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (((int) reloc->r_symndx) > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
relent->address -= section->vma;
|
||||
}
|
||||
|
||||
#define BADMAG(x) MC88BADMAG(x)
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_write_armap
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (m88kbcs_vec, "coff-m88kbcs", 0, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
597
bfd/coff-mcore.c
597
bfd/coff-mcore.c
@@ -1,597 +0,0 @@
|
||||
/* BFD back-end for Motorola MCore COFF/PE
|
||||
Copyright 1999, 2000, 2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/mcore.h"
|
||||
#include "coff/internal.h"
|
||||
#include "coff/pe.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#ifdef BADMAG
|
||||
#undef BADMAG
|
||||
#endif
|
||||
#define BADMAG(x) MCOREBADMAG(x)
|
||||
|
||||
#ifndef NUM_ELEM
|
||||
#define NUM_ELEM(A) (sizeof (A) / sizeof (A)[0])
|
||||
#endif
|
||||
|
||||
/* This file is compiled more than once, but we only compile the
|
||||
final_link routine once. */
|
||||
extern bfd_boolean mcore_bfd_coff_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
#if 0
|
||||
static struct bfd_link_hash_table *coff_mcore_link_hash_table_create
|
||||
PARAMS ((bfd *));
|
||||
#endif
|
||||
static bfd_reloc_status_type mcore_coff_unsupported_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean coff_mcore_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static reloc_howto_type *mcore_coff_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static reloc_howto_type *coff_mcore_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
static void mcore_emit_base_file_entry
|
||||
PARAMS ((struct bfd_link_info *, bfd *, asection *, bfd_vma));
|
||||
static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
|
||||
|
||||
/* The NT loader points the toc register to &toc + 32768, in order to
|
||||
use the complete range of a 16-bit displacement. We have to adjust
|
||||
for this when we fix up loads displaced off the toc reg. */
|
||||
#define TOC_LOAD_ADJUSTMENT (-32768)
|
||||
#define TOC_SECTION_NAME ".private.toc"
|
||||
|
||||
/* The main body of code is in coffcode.h. */
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2
|
||||
|
||||
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
|
||||
from smaller values. Start with zero, widen, *then* decrement. */
|
||||
#define MINUS_ONE (((bfd_vma)0) - 1)
|
||||
|
||||
static reloc_howto_type mcore_coff_howto_table[] =
|
||||
{
|
||||
/* Unused: */
|
||||
HOWTO (IMAGE_REL_MCORE_ABSOLUTE,/* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
0, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* dont complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"ABSOLUTE", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x00, /* src_mask */
|
||||
0x00, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (IMAGE_REL_MCORE_ADDR32,/* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"ADDR32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
/* 8 bits + 2 zero bits; jmpi/jsri/lrw instructions.
|
||||
Should not appear in object files. */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_IMM8BY4, /* type */
|
||||
2, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
mcore_coff_unsupported_reloc, /* special_function */
|
||||
"IMM8BY4", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
/* bsr/bt/bf/br instructions; 11 bits + 1 zero bit
|
||||
Span 2k instructions == 4k bytes.
|
||||
Only useful pieces at the relocated address are the opcode (5 bits) */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_IMM11BY2,/* type */
|
||||
1, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
11, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"IMM11BY2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0, /* src_mask */
|
||||
0x7ff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
/* 4 bits + 1 zero bit; 'loopt' instruction only; unsupported. */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_IMM4BY2, /* type */
|
||||
1, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
4, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
mcore_coff_unsupported_reloc, /* special_function */
|
||||
"IMM4BY2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
/* 32-bit pc-relative. Eventually this will help support PIC code. */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_32,/* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PCREL_32", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
/* Like PCREL_IMM11BY2, this relocation indicates that there is a
|
||||
'jsri' at the specified address. There is a separate relocation
|
||||
entry for the literal pool entry that it references, but we
|
||||
might be able to change the jsri to a bsr if the target turns out
|
||||
to be close enough [even though we won't reclaim the literal pool
|
||||
entry, we'll get some runtime efficiency back]. Note that this
|
||||
is a relocation that we are allowed to safely ignore. */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2,/* type */
|
||||
1, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
11, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"JSR_IMM11BY2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0, /* src_mask */
|
||||
0x7ff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (IMAGE_REL_MCORE_RVA, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"MCORE_RVA", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Extend the coff_link_hash_table structure with a few M*Core specific fields.
|
||||
This allows us to store global data here without actually creating any
|
||||
global variables, which is a no-no in the BFD world. */
|
||||
typedef struct coff_mcore_link_hash_table
|
||||
{
|
||||
/* The original coff_link_hash_table structure. MUST be first field. */
|
||||
struct coff_link_hash_table root;
|
||||
|
||||
bfd * bfd_of_toc_owner;
|
||||
long int global_toc_size;
|
||||
long int import_table_size;
|
||||
long int first_thunk_address;
|
||||
long int thunk_size;
|
||||
}
|
||||
mcore_hash_table;
|
||||
|
||||
/* Get the MCore coff linker hash table from a link_info structure. */
|
||||
#define coff_mcore_hash_table(info) \
|
||||
((mcore_hash_table *) ((info)->hash))
|
||||
|
||||
#if 0
|
||||
/* Create an MCore coff linker hash table. */
|
||||
|
||||
static struct bfd_link_hash_table *
|
||||
coff_mcore_link_hash_table_create (abfd)
|
||||
bfd * abfd;
|
||||
{
|
||||
mcore_hash_table * ret;
|
||||
|
||||
ret = (mcore_hash_table *) bfd_malloc ((bfd_size_type) sizeof (* ret));
|
||||
if (ret == (mcore_hash_table *) NULL)
|
||||
return NULL;
|
||||
|
||||
if (! _bfd_coff_link_hash_table_init
|
||||
(& ret->root, abfd, _bfd_coff_link_hash_newfunc))
|
||||
{
|
||||
free (ret);
|
||||
return (struct bfd_link_hash_table *) NULL;
|
||||
}
|
||||
|
||||
ret->bfd_of_toc_owner = NULL;
|
||||
ret->global_toc_size = 0;
|
||||
ret->import_table_size = 0;
|
||||
ret->first_thunk_address = 0;
|
||||
ret->thunk_size = 0;
|
||||
|
||||
return & ret->root.root;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Add an entry to the base file. */
|
||||
|
||||
static void
|
||||
mcore_emit_base_file_entry (info, output_bfd, input_section, reloc_offset)
|
||||
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;
|
||||
|
||||
fwrite (&addr, 1, sizeof (addr), (FILE *) info->base_file);
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
mcore_coff_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd * abfd;
|
||||
arelent * reloc_entry;
|
||||
asymbol * symbol ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection * input_section ATTRIBUTE_UNUSED;
|
||||
bfd * output_bfd ATTRIBUTE_UNUSED;
|
||||
char ** error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
|
||||
|
||||
_bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"),
|
||||
abfd,
|
||||
reloc_entry->howto->name,
|
||||
reloc_entry->howto->type);
|
||||
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
|
||||
/* A cheesy little macro to make the code a little more readable. */
|
||||
#define HOW2MAP(bfd_rtype, mcore_rtype) \
|
||||
case bfd_rtype: return & mcore_coff_howto_table [mcore_rtype]
|
||||
|
||||
static reloc_howto_type *
|
||||
mcore_coff_reloc_type_lookup (abfd, code)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
HOW2MAP (BFD_RELOC_32, IMAGE_REL_MCORE_ADDR32);
|
||||
HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM8BY4, IMAGE_REL_MCORE_PCREL_IMM8BY4);
|
||||
HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM11BY2, IMAGE_REL_MCORE_PCREL_IMM11BY2);
|
||||
HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM4BY2, IMAGE_REL_MCORE_PCREL_IMM4BY2);
|
||||
HOW2MAP (BFD_RELOC_32_PCREL, IMAGE_REL_MCORE_PCREL_32);
|
||||
HOW2MAP (BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2);
|
||||
HOW2MAP (BFD_RELOC_RVA, IMAGE_REL_MCORE_RVA);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
#undef HOW2MAP
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = mcore_coff_howto_table + (dst)->r_type;
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_mcore_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
asection * sec;
|
||||
struct internal_reloc * rel;
|
||||
struct coff_link_hash_entry * h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment * sym;
|
||||
bfd_vma * addendp;
|
||||
{
|
||||
reloc_howto_type * howto;
|
||||
|
||||
if (rel->r_type >= NUM_ELEM (mcore_coff_howto_table))
|
||||
return NULL;
|
||||
|
||||
howto = mcore_coff_howto_table + rel->r_type;
|
||||
|
||||
if (rel->r_type == IMAGE_REL_MCORE_RVA)
|
||||
* addendp -= pe_data (sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
|
||||
else if (howto->pc_relative)
|
||||
{
|
||||
* addendp = sec->vma - 2; /* XXX guess - is this right ? */
|
||||
|
||||
/* If the symbol is defined, then the generic code is going to
|
||||
add back the symbol value in order to cancel out an
|
||||
adjustment it made to the addend. However, we set the addend
|
||||
to 0 at the start of this function. We need to adjust here,
|
||||
to avoid the adjustment the generic code will make. FIXME:
|
||||
This is getting a bit hackish. */
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
* addendp -= sym->n_value;
|
||||
}
|
||||
else
|
||||
* addendp = 0;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
/* Return TRUE if this relocation should appear in the output .reloc section.
|
||||
This function is referenced in pe_mkobject in peicode.h. */
|
||||
|
||||
static bfd_boolean
|
||||
in_reloc_p (abfd, howto)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
reloc_howto_type * howto;
|
||||
{
|
||||
return ! howto->pc_relative && howto->type != IMAGE_REL_MCORE_RVA;
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
static bfd_boolean
|
||||
coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd * output_bfd;
|
||||
struct bfd_link_info * info;
|
||||
bfd * input_bfd;
|
||||
asection * input_section;
|
||||
bfd_byte * contents;
|
||||
struct internal_reloc * relocs;
|
||||
struct internal_syment * syms;
|
||||
asection ** sections;
|
||||
{
|
||||
struct internal_reloc * rel;
|
||||
struct internal_reloc * relend;
|
||||
bfd_boolean hihalf;
|
||||
bfd_vma hihalf_val;
|
||||
|
||||
/* If we are performing a relocatable link, we don't need to do a
|
||||
thing. The caller will take care of adjusting the reloc
|
||||
addresses and symbol indices. */
|
||||
if (info->relocatable)
|
||||
return TRUE;
|
||||
|
||||
/* Check if we have the same endianess */
|
||||
if ( input_bfd->xvec->byteorder != output_bfd->xvec->byteorder
|
||||
&& output_bfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: compiled for a %s system and target is %s.\n"),
|
||||
input_bfd,
|
||||
bfd_big_endian (input_bfd) ? _("big endian") : _("little endian"),
|
||||
bfd_big_endian (output_bfd) ? _("big endian") : _("little endian"));
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hihalf = FALSE;
|
||||
hihalf_val = 0;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
struct internal_syment * sym;
|
||||
bfd_vma val;
|
||||
bfd_vma addend;
|
||||
bfd_reloc_status_type rstat;
|
||||
bfd_byte * loc;
|
||||
unsigned short r_type = rel->r_type;
|
||||
reloc_howto_type * howto = NULL;
|
||||
struct coff_link_hash_entry * h;
|
||||
const char * my_name;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
loc = contents + rel->r_vaddr - input_section->vma;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
h = NULL;
|
||||
sym = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
sym = syms + symndx;
|
||||
}
|
||||
|
||||
addend = 0;
|
||||
|
||||
/* Get the howto and initialise the addend. */
|
||||
howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
|
||||
sym, & addend);
|
||||
if (howto == NULL)
|
||||
return FALSE;
|
||||
|
||||
val = 0;
|
||||
|
||||
if (h == NULL)
|
||||
{
|
||||
if (symndx == -1)
|
||||
my_name = "*ABS*";
|
||||
else
|
||||
{
|
||||
asection * sec = sections[symndx];
|
||||
|
||||
val = (sym->n_value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
|
||||
if (sym == NULL)
|
||||
my_name = "*unknown*";
|
||||
else if ( sym->_n._n_n._n_zeroes == 0
|
||||
&& sym->_n._n_n._n_offset != 0)
|
||||
my_name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
|
||||
else
|
||||
{
|
||||
static char buf [SYMNMLEN + 1];
|
||||
|
||||
strncpy (buf, sym->_n._n_name, SYMNMLEN);
|
||||
buf[SYMNMLEN] = '\0';
|
||||
my_name = buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection * sec = h->root.u.def.section;
|
||||
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma, TRUE)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
my_name = h->root.root.string;
|
||||
}
|
||||
|
||||
rstat = bfd_reloc_ok;
|
||||
|
||||
/* Each case must do its own relocation, setting rstat appropriately. */
|
||||
switch (r_type)
|
||||
{
|
||||
default:
|
||||
_bfd_error_handler (_("%B: unsupported relocation type 0x%02x"),
|
||||
input_bfd, r_type);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return FALSE;
|
||||
|
||||
case IMAGE_REL_MCORE_ABSOLUTE:
|
||||
_bfd_error_handler
|
||||
(_("Warning: unsupported reloc %s <file %B, section %A>\n"
|
||||
"sym %ld (%s), r_vaddr %ld (%lx)"),
|
||||
input_bfd, input_section, howto->name,
|
||||
rel->r_symndx, my_name, (long) rel->r_vaddr,
|
||||
(unsigned long) rel->r_vaddr);
|
||||
break;
|
||||
|
||||
case IMAGE_REL_MCORE_PCREL_IMM8BY4:
|
||||
case IMAGE_REL_MCORE_PCREL_IMM11BY2:
|
||||
case IMAGE_REL_MCORE_PCREL_IMM4BY2:
|
||||
case IMAGE_REL_MCORE_PCREL_32:
|
||||
case IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2:
|
||||
case IMAGE_REL_MCORE_ADDR32:
|
||||
/* XXX fixme - shouldn't this be like the code for the RVA reloc ? */
|
||||
rstat = _bfd_relocate_contents (howto, input_bfd, val, loc);
|
||||
break;
|
||||
|
||||
case IMAGE_REL_MCORE_RVA:
|
||||
rstat = _bfd_final_link_relocate
|
||||
(howto, input_bfd,
|
||||
input_section, contents, rel->r_vaddr - input_section->vma,
|
||||
val, addend);
|
||||
break;
|
||||
}
|
||||
|
||||
if (info->base_file)
|
||||
{
|
||||
/* Emit a reloc if the backend thinks it needs it. */
|
||||
if (sym && pe_data (output_bfd)->in_reloc_p (output_bfd, howto))
|
||||
mcore_emit_base_file_entry (info, output_bfd, input_section, rel->r_vaddr);
|
||||
}
|
||||
|
||||
switch (rstat)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
|
||||
case bfd_reloc_ok:
|
||||
break;
|
||||
|
||||
case bfd_reloc_overflow:
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, my_name, howto->name,
|
||||
(bfd_vma) 0, input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Tailor coffcode.h -- macro heaven. */
|
||||
|
||||
/* We use the special COFF backend linker, with our own special touch. */
|
||||
|
||||
#define coff_bfd_reloc_type_lookup mcore_coff_reloc_type_lookup
|
||||
#define coff_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)
|
||||
1532
bfd/coff-mips.c
1532
bfd/coff-mips.c
File diff suppressed because it is too large
Load Diff
662
bfd/coff-or32.c
662
bfd/coff-or32.c
@@ -1,662 +0,0 @@
|
||||
/* BFD back-end for OpenRISC 1000 COFF binaries.
|
||||
Copyright 2002, 2003 Free Software Foundation, Inc.
|
||||
Contributed by Ivan Guzvinec <ivang@opencores.org>
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define OR32 1
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/or32.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static long get_symbol_value
|
||||
PARAMS ((asymbol *));
|
||||
static bfd_reloc_status_type or32_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean coff_or32_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static bfd_boolean coff_or32_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, bfd_boolean *));
|
||||
static void reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
#define INSERT_HWORD(WORD,HWORD) \
|
||||
(((WORD) & 0xffff0000) | ((HWORD)& 0x0000ffff))
|
||||
#define EXTRACT_HWORD(WORD) \
|
||||
((WORD) & 0x0000ffff)
|
||||
#define SIGN_EXTEND_HWORD(HWORD) \
|
||||
((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD))
|
||||
|
||||
#define INSERT_JUMPTARG(WORD,JT) \
|
||||
(((WORD) & 0xfc000000) | ((JT)& 0x03ffffff))
|
||||
#define EXTRACT_JUMPTARG(WORD) \
|
||||
((WORD) & 0x03ffffff)
|
||||
#define SIGN_EXTEND_JUMPTARG(JT) \
|
||||
((JT) & 0x04000000 ? (JT)|(~0x03ffffffL) : (JT))
|
||||
|
||||
/* Provided the symbol, returns the value reffed. */
|
||||
|
||||
static long
|
||||
get_symbol_value (symbol)
|
||||
asymbol *symbol;
|
||||
{
|
||||
long relocation = 0;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
relocation = 0;
|
||||
else
|
||||
relocation = symbol->value +
|
||||
symbol->section->output_section->vma +
|
||||
symbol->section->output_offset;
|
||||
|
||||
return relocation;
|
||||
}
|
||||
|
||||
/* This function is in charge of performing all the or32 relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
or32_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol_in;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* The consth relocation comes in two parts, we have to remember
|
||||
the state between calls, in these variables. */
|
||||
static bfd_boolean part1_consth_active = FALSE;
|
||||
static unsigned long part1_consth_value;
|
||||
|
||||
unsigned long insn;
|
||||
unsigned long sym_value;
|
||||
unsigned long unsigned_value;
|
||||
unsigned short r_type;
|
||||
long signed_value;
|
||||
|
||||
unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
|
||||
bfd_byte *hit_data =addr + (bfd_byte *)(data);
|
||||
|
||||
r_type = reloc_entry->howto->type;
|
||||
|
||||
if (output_bfd)
|
||||
{
|
||||
/* Partial linking - do nothing. */
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
if (symbol_in != NULL
|
||||
&& bfd_is_und_section (symbol_in->section))
|
||||
{
|
||||
/* Keep the state machine happy in case we're called again. */
|
||||
if (r_type == R_IHIHALF)
|
||||
{
|
||||
part1_consth_active = TRUE;
|
||||
part1_consth_value = 0;
|
||||
}
|
||||
|
||||
return bfd_reloc_undefined;
|
||||
}
|
||||
|
||||
if ((part1_consth_active) && (r_type != R_IHCONST))
|
||||
{
|
||||
part1_consth_active = FALSE;
|
||||
*error_message = (char *) "Missing IHCONST";
|
||||
|
||||
return bfd_reloc_dangerous;
|
||||
}
|
||||
|
||||
sym_value = get_symbol_value (symbol_in);
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
case R_IREL:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
|
||||
/* Take the value in the field and sign extend it. */
|
||||
signed_value = EXTRACT_JUMPTARG (insn);
|
||||
signed_value = SIGN_EXTEND_JUMPTARG (signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* See the note on the R_IREL reloc in coff_or32_relocate_section. */
|
||||
if (signed_value == - (long) reloc_entry->address)
|
||||
signed_value = 0;
|
||||
|
||||
signed_value += sym_value + reloc_entry->addend;
|
||||
#if 0
|
||||
if ((signed_value & ~0x3ffff) == 0)
|
||||
{ /* Absolute jmp/call. */
|
||||
insn |= (1<<24); /* Make it absolute. */
|
||||
/* FIXME: Should we change r_type to R_IABS. */
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Relative jmp/call, so subtract from the value the
|
||||
address of the place we're coming from. */
|
||||
signed_value -= (reloc_entry->address
|
||||
+ input_section->output_section->vma
|
||||
+ input_section->output_offset);
|
||||
if (signed_value > 0x7ffffff || signed_value < -0x8000000)
|
||||
return bfd_reloc_overflow;
|
||||
}
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_JUMPTARG (insn, signed_value);
|
||||
bfd_put_32 (abfd, insn, hit_data);
|
||||
break;
|
||||
|
||||
case R_ILOHALF:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
unsigned_value = EXTRACT_HWORD (insn);
|
||||
unsigned_value += sym_value + reloc_entry->addend;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (abfd, insn, hit_data);
|
||||
break;
|
||||
|
||||
case R_IHIHALF:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
|
||||
/* consth, part 1
|
||||
Just get the symbol value that is referenced. */
|
||||
part1_consth_active = TRUE;
|
||||
part1_consth_value = sym_value + reloc_entry->addend;
|
||||
|
||||
/* Don't modify insn until R_IHCONST. */
|
||||
break;
|
||||
|
||||
case R_IHCONST:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
|
||||
/* consth, part 2
|
||||
Now relocate the reference. */
|
||||
if (! part1_consth_active)
|
||||
{
|
||||
*error_message = (char *) "Missing IHIHALF";
|
||||
return bfd_reloc_dangerous;
|
||||
}
|
||||
|
||||
/* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */
|
||||
unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/
|
||||
unsigned_value += reloc_entry->addend; /* r_symndx */
|
||||
unsigned_value += part1_consth_value;
|
||||
unsigned_value = unsigned_value >> 16;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
part1_consth_active = FALSE;
|
||||
bfd_put_32 (abfd, insn, hit_data);
|
||||
break;
|
||||
|
||||
case R_BYTE:
|
||||
insn = bfd_get_8 (abfd, hit_data);
|
||||
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||
if (unsigned_value & 0xffffff00)
|
||||
return bfd_reloc_overflow;
|
||||
bfd_put_8 (abfd, unsigned_value, hit_data);
|
||||
break;
|
||||
|
||||
case R_HWORD:
|
||||
insn = bfd_get_16 (abfd, hit_data);
|
||||
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||
if (unsigned_value & 0xffff0000)
|
||||
return bfd_reloc_overflow;
|
||||
bfd_put_16 (abfd, insn, hit_data);
|
||||
break;
|
||||
|
||||
case R_WORD:
|
||||
insn = bfd_get_32 (abfd, hit_data);
|
||||
insn += sym_value + reloc_entry->addend;
|
||||
bfd_put_32 (abfd, insn, hit_data);
|
||||
break;
|
||||
|
||||
default:
|
||||
*error_message = _("Unrecognized reloc");
|
||||
return bfd_reloc_dangerous;
|
||||
}
|
||||
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
/* type rightshift
|
||||
size
|
||||
bitsize
|
||||
pc-relative
|
||||
bitpos
|
||||
absolute
|
||||
complain_on_overflow
|
||||
special_function
|
||||
relocation name
|
||||
partial_inplace
|
||||
src_mask
|
||||
*/
|
||||
|
||||
/* FIXME: I'm not real sure about this table. */
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{ R_ABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "ABS", TRUE, 0xffffffff,0xffffffff, FALSE },
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
EMPTY_HOWTO (6),
|
||||
EMPTY_HOWTO (7),
|
||||
EMPTY_HOWTO (8),
|
||||
EMPTY_HOWTO (9),
|
||||
EMPTY_HOWTO (10),
|
||||
EMPTY_HOWTO (11),
|
||||
EMPTY_HOWTO (12),
|
||||
EMPTY_HOWTO (13),
|
||||
EMPTY_HOWTO (14),
|
||||
EMPTY_HOWTO (15),
|
||||
EMPTY_HOWTO (16),
|
||||
EMPTY_HOWTO (17),
|
||||
EMPTY_HOWTO (18),
|
||||
EMPTY_HOWTO (19),
|
||||
EMPTY_HOWTO (20),
|
||||
EMPTY_HOWTO (21),
|
||||
EMPTY_HOWTO (22),
|
||||
EMPTY_HOWTO (23),
|
||||
{ R_IREL, 0, 3, 32, TRUE, 0, complain_overflow_signed, or32_reloc, "IREL", TRUE, 0xffffffff,0xffffffff, FALSE },
|
||||
{ R_IABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "IABS", TRUE, 0xffffffff,0xffffffff, FALSE },
|
||||
{ R_ILOHALF, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "ILOHALF", TRUE, 0x0000ffff,0x0000ffff, FALSE },
|
||||
{ R_IHIHALF, 0, 3, 16, TRUE, 16,complain_overflow_signed, or32_reloc, "IHIHALF", TRUE, 0xffff0000,0xffff0000, FALSE },
|
||||
{ R_IHCONST, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "IHCONST", TRUE, 0xffff0000,0xffff0000, FALSE },
|
||||
{ R_BYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, or32_reloc, "BYTE", TRUE, 0x000000ff,0x000000ff, FALSE },
|
||||
{ R_HWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, or32_reloc, "HWORD", TRUE, 0x0000ffff,0x0000ffff, FALSE },
|
||||
{ R_WORD, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "WORD", TRUE, 0xffffffff,0xffffffff, FALSE },
|
||||
};
|
||||
|
||||
#define BADMAG(x) OR32BADMAG (x)
|
||||
|
||||
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
|
||||
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent,reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
|
||||
|
||||
relent->address = reloc->r_vaddr;
|
||||
relent->howto = howto_table + reloc->r_type;
|
||||
|
||||
if (reloc->r_type == R_IHCONST)
|
||||
{
|
||||
/* The address of an R_IHCONST should always be the address of
|
||||
the immediately preceding R_IHIHALF. relocs generated by gas
|
||||
are correct, but relocs generated by High C are different (I
|
||||
can't figure out what the address means for High C). We can
|
||||
handle both gas and High C by ignoring the address here, and
|
||||
simply reusing the address saved for R_IHIHALF. */
|
||||
if (ihihalf_vaddr == (bfd_vma) -1)
|
||||
abort ();
|
||||
|
||||
relent->address = ihihalf_vaddr;
|
||||
ihihalf_vaddr = (bfd_vma) -1;
|
||||
relent->addend = reloc->r_symndx;
|
||||
relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
asymbol *ptr;
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
|
||||
relent->addend = 0;
|
||||
relent->address-= section->vma;
|
||||
|
||||
if (reloc->r_type == R_IHIHALF)
|
||||
ihihalf_vaddr = relent->address;
|
||||
else if (ihihalf_vaddr != (bfd_vma) -1)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_or32_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
struct internal_reloc *rel;
|
||||
struct internal_reloc *relend;
|
||||
bfd_boolean hihalf;
|
||||
bfd_vma hihalf_val;
|
||||
|
||||
/* If we are performing a relocatable link, we don't need to do a
|
||||
thing. The caller will take care of adjusting the reloc
|
||||
addresses and symbol indices. */
|
||||
if (info->relocatable)
|
||||
return TRUE;
|
||||
|
||||
hihalf = FALSE;
|
||||
hihalf_val = 0;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
bfd_byte *loc;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
asection *sec;
|
||||
bfd_vma val;
|
||||
bfd_boolean overflow;
|
||||
unsigned long insn;
|
||||
long signed_value;
|
||||
unsigned long unsigned_value;
|
||||
bfd_reloc_status_type rstat;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
loc = contents + rel->r_vaddr - input_section->vma;
|
||||
|
||||
if (symndx == -1 || rel->r_type == R_IHCONST)
|
||||
h = NULL;
|
||||
else
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
|
||||
sym = NULL;
|
||||
sec = NULL;
|
||||
val = 0;
|
||||
|
||||
/* An R_IHCONST reloc does not have a symbol. Instead, the
|
||||
symbol index is an addend. R_IHCONST is always used in
|
||||
conjunction with R_IHHALF. */
|
||||
if (rel->r_type != R_IHCONST)
|
||||
{
|
||||
if (h == NULL)
|
||||
{
|
||||
if (symndx == -1)
|
||||
sec = bfd_abs_section_ptr;
|
||||
else
|
||||
{
|
||||
sym = syms + symndx;
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value
|
||||
- sec->vma);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma, TRUE)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (hihalf)
|
||||
{
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info, "missing IHCONST reloc", input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
hihalf = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
overflow = FALSE;
|
||||
|
||||
switch (rel->r_type)
|
||||
{
|
||||
default:
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return FALSE;
|
||||
|
||||
case R_IREL:
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
|
||||
/* Extract the addend. */
|
||||
signed_value = EXTRACT_JUMPTARG (insn);
|
||||
signed_value = SIGN_EXTEND_JUMPTARG (signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* Determine the destination of the jump. */
|
||||
signed_value += val;
|
||||
|
||||
#if 0
|
||||
if ((signed_value & ~0x3ffff) == 0)
|
||||
{
|
||||
/* We can use an absolute jump. */
|
||||
insn |= (1 << 24);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Make the destination PC relative. */
|
||||
signed_value -= (input_section->output_section->vma
|
||||
+ input_section->output_offset
|
||||
+ (rel->r_vaddr - input_section->vma));
|
||||
if (signed_value > 0x7ffffff || signed_value < - 0x8000000)
|
||||
{
|
||||
overflow = TRUE;
|
||||
signed_value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Put the adjusted value back into the instruction. */
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_JUMPTARG(insn, signed_value);
|
||||
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
break;
|
||||
|
||||
case R_ILOHALF:
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
unsigned_value = EXTRACT_HWORD (insn);
|
||||
unsigned_value += val;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (input_bfd, insn, loc);
|
||||
break;
|
||||
|
||||
case R_IHIHALF:
|
||||
/* Save the value for the R_IHCONST reloc. */
|
||||
hihalf = TRUE;
|
||||
hihalf_val = val;
|
||||
break;
|
||||
|
||||
case R_IHCONST:
|
||||
if (! hihalf)
|
||||
{
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info, "missing IHIHALF reloc", input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
hihalf_val = 0;
|
||||
}
|
||||
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
unsigned_value = rel->r_symndx + hihalf_val;
|
||||
unsigned_value >>= 16;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
|
||||
hihalf = FALSE;
|
||||
break;
|
||||
|
||||
case R_BYTE:
|
||||
case R_HWORD:
|
||||
case R_WORD:
|
||||
rstat = _bfd_relocate_contents (howto_table + rel->r_type,
|
||||
input_bfd, val, loc);
|
||||
if (rstat == bfd_reloc_overflow)
|
||||
overflow = TRUE;
|
||||
else if (rstat != bfd_reloc_ok)
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else if (sym == NULL)
|
||||
name = "*unknown*";
|
||||
else if (sym->_n._n_n._n_zeroes == 0
|
||||
&& sym->_n._n_n._n_offset != 0)
|
||||
name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
|
||||
else
|
||||
{
|
||||
strncpy (buf, sym->_n._n_name, SYMNMLEN);
|
||||
buf[SYMNMLEN] = '\0';
|
||||
name = buf;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto_table[rel->r_type].name, (bfd_vma) 0,
|
||||
input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define coff_relocate_section coff_or32_relocate_section
|
||||
|
||||
/* We don't want to change the symndx of a R_IHCONST reloc, since it
|
||||
is actually an addend, not a symbol index at all. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_or32_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
||||
bfd *ibfd ATTRIBUTE_UNUSED;
|
||||
asection *sec ATTRIBUTE_UNUSED;
|
||||
struct internal_reloc *irel;
|
||||
bfd_boolean *adjustedp;
|
||||
{
|
||||
if (irel->r_type == R_IHCONST)
|
||||
*adjustedp = TRUE;
|
||||
else
|
||||
*adjustedp = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define coff_adjust_symndx coff_or32_adjust_symndx
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target or32coff_big_vec =
|
||||
{
|
||||
"coff-or32-big", /* Name. */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* Data byte order is big. */
|
||||
BFD_ENDIAN_BIG, /* Header byte order is big. */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* Object flags. */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | /* Section flags. */
|
||||
SEC_LOAD | SEC_RELOC |
|
||||
SEC_READONLY ),
|
||||
'_', /* Leading underscore. */
|
||||
'/', /* ar_pad_char. */
|
||||
15, /* ar_max_namelen. */
|
||||
|
||||
/* Data. */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||
|
||||
/* Headers. */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||
|
||||
{
|
||||
_bfd_dummy_target,
|
||||
coff_object_p,
|
||||
bfd_generic_archive_p,
|
||||
_bfd_dummy_target
|
||||
},
|
||||
{
|
||||
bfd_false,
|
||||
coff_mkobject,
|
||||
_bfd_generic_mkarchive,
|
||||
bfd_false
|
||||
},
|
||||
{
|
||||
bfd_false,
|
||||
coff_write_object_contents,
|
||||
_bfd_write_archive_contents,
|
||||
bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
/* Alternative_target. */
|
||||
#ifdef TARGET_LITTLE_SYM
|
||||
& TARGET_LITTLE_SYM,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
/* BFD back-end for Apple et al PowerPC Mac "XCOFF" files.
|
||||
Copyright 1995, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Tweak coffcode.h based on this being a PowerMac instead of RS/6000. */
|
||||
|
||||
#define POWERMAC
|
||||
|
||||
#define TARGET_SYM pmac_xcoff_vec
|
||||
#define TARGET_NAME "xcoff-powermac"
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/internal.h"
|
||||
#include "coff/rs6000.h"
|
||||
#include "libcoff.h"
|
||||
#include "xcoff-target.h"
|
||||
2865
bfd/coff-ppc.c
2865
bfd/coff-ppc.c
File diff suppressed because it is too large
Load Diff
4462
bfd/coff-rs6000.c
4462
bfd/coff-rs6000.c
File diff suppressed because it is too large
Load Diff
3293
bfd/coff-sh.c
3293
bfd/coff-sh.c
File diff suppressed because it is too large
Load Diff
219
bfd/coff-sparc.c
219
bfd/coff-sparc.c
@@ -1,219 +0,0 @@
|
||||
/* BFD back-end for Sparc COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
|
||||
2002, 2003 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/sparc.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
#define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC)
|
||||
|
||||
/* The page size is a guess based on ELF. */
|
||||
#define COFF_PAGE_SIZE 0x10000
|
||||
|
||||
|
||||
static reloc_howto_type *coff_sparc_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
|
||||
enum reloc_type
|
||||
{
|
||||
R_SPARC_NONE = 0,
|
||||
R_SPARC_8, R_SPARC_16, R_SPARC_32,
|
||||
R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
|
||||
R_SPARC_WDISP30, R_SPARC_WDISP22,
|
||||
R_SPARC_HI22, R_SPARC_22,
|
||||
R_SPARC_13, R_SPARC_LO10,
|
||||
R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
|
||||
R_SPARC_PC10, R_SPARC_PC22,
|
||||
R_SPARC_WPLT30,
|
||||
R_SPARC_COPY,
|
||||
R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
|
||||
R_SPARC_RELATIVE,
|
||||
R_SPARC_UA32,
|
||||
R_SPARC_max
|
||||
};
|
||||
|
||||
#if 0
|
||||
static const char *const reloc_type_names[] =
|
||||
{
|
||||
"R_SPARC_NONE",
|
||||
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
|
||||
"R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
|
||||
"R_SPARC_WDISP30", "R_SPARC_WDISP22",
|
||||
"R_SPARC_HI22", "R_SPARC_22",
|
||||
"R_SPARC_13", "R_SPARC_LO10",
|
||||
"R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
|
||||
"R_SPARC_PC10", "R_SPARC_PC22",
|
||||
"R_SPARC_WPLT30",
|
||||
"R_SPARC_COPY",
|
||||
"R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
|
||||
"R_SPARC_RELATIVE",
|
||||
"R_SPARC_UA32",
|
||||
};
|
||||
#endif
|
||||
|
||||
/* This is stolen pretty directly from elf.c. */
|
||||
static bfd_reloc_status_type
|
||||
bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
static bfd_reloc_status_type
|
||||
bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
if (output_bfd != (bfd *) NULL
|
||||
&& (symbol->flags & BSF_SECTION_SYM) == 0)
|
||||
{
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
static reloc_howto_type coff_sparc_howto_table[] =
|
||||
{
|
||||
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_NONE", FALSE,0,0x00000000,TRUE),
|
||||
HOWTO(R_SPARC_8, 0,0, 8,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_8", FALSE,0,0x000000ff,TRUE),
|
||||
HOWTO(R_SPARC_16, 0,1,16,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_16", FALSE,0,0x0000ffff,TRUE),
|
||||
HOWTO(R_SPARC_32, 0,2,32,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_32", FALSE,0,0xffffffff,TRUE),
|
||||
HOWTO(R_SPARC_DISP8, 0,0, 8,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP8", FALSE,0,0x000000ff,TRUE),
|
||||
HOWTO(R_SPARC_DISP16, 0,1,16,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP16", FALSE,0,0x0000ffff,TRUE),
|
||||
HOWTO(R_SPARC_DISP32, 0,2,32,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP32", FALSE,0,0x00ffffff,TRUE),
|
||||
HOWTO(R_SPARC_WDISP30, 2,2,30,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP30", FALSE,0,0x3fffffff,TRUE),
|
||||
HOWTO(R_SPARC_WDISP22, 2,2,22,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP22", FALSE,0,0x003fffff,TRUE),
|
||||
HOWTO(R_SPARC_HI22, 10,2,22,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_HI22", FALSE,0,0x003fffff,TRUE),
|
||||
HOWTO(R_SPARC_22, 0,2,22,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_22", FALSE,0,0x003fffff,TRUE),
|
||||
HOWTO(R_SPARC_13, 0,2,13,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_13", FALSE,0,0x00001fff,TRUE),
|
||||
HOWTO(R_SPARC_LO10, 0,2,10,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_LO10", FALSE,0,0x000003ff,TRUE),
|
||||
HOWTO(R_SPARC_GOT10, 0,2,10,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT10", FALSE,0,0x000003ff,TRUE),
|
||||
HOWTO(R_SPARC_GOT13, 0,2,13,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT13", FALSE,0,0x00001fff,TRUE),
|
||||
HOWTO(R_SPARC_GOT22, 10,2,22,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT22", FALSE,0,0x003fffff,TRUE),
|
||||
HOWTO(R_SPARC_PC10, 0,2,10,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC10", FALSE,0,0x000003ff,TRUE),
|
||||
HOWTO(R_SPARC_PC22, 0,2,22,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC22", FALSE,0,0x003fffff,TRUE),
|
||||
HOWTO(R_SPARC_WPLT30, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_WPLT30", FALSE,0,0x00000000,TRUE),
|
||||
HOWTO(R_SPARC_COPY, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_COPY", FALSE,0,0x00000000,TRUE),
|
||||
HOWTO(R_SPARC_GLOB_DAT,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_GLOB_DAT",FALSE,0,0x00000000,TRUE),
|
||||
HOWTO(R_SPARC_JMP_SLOT,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_JMP_SLOT",FALSE,0,0x00000000,TRUE),
|
||||
HOWTO(R_SPARC_RELATIVE,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_RELATIVE",FALSE,0,0x00000000,TRUE),
|
||||
HOWTO(R_SPARC_UA32, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_UA32", FALSE,0,0x00000000,TRUE),
|
||||
};
|
||||
|
||||
struct coff_reloc_map {
|
||||
bfd_reloc_code_real_type bfd_reloc_val;
|
||||
unsigned char coff_reloc_val;
|
||||
};
|
||||
|
||||
static const struct coff_reloc_map sparc_reloc_map[] =
|
||||
{
|
||||
{ BFD_RELOC_NONE, R_SPARC_NONE, },
|
||||
{ BFD_RELOC_16, R_SPARC_16, },
|
||||
{ BFD_RELOC_8, R_SPARC_8 },
|
||||
{ BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
|
||||
{ BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
|
||||
{ BFD_RELOC_32, R_SPARC_32 },
|
||||
{ BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
|
||||
{ BFD_RELOC_HI22, R_SPARC_HI22 },
|
||||
{ BFD_RELOC_LO10, R_SPARC_LO10, },
|
||||
{ BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
|
||||
{ BFD_RELOC_SPARC22, R_SPARC_22 },
|
||||
{ BFD_RELOC_SPARC13, R_SPARC_13 },
|
||||
{ BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
|
||||
{ BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
|
||||
{ BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
|
||||
{ BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
|
||||
{ BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
|
||||
{ BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
|
||||
{ BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
|
||||
{ BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
|
||||
{ BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
|
||||
{ BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
|
||||
{ BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
|
||||
/* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
|
||||
};
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_sparc_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
|
||||
{
|
||||
if (sparc_reloc_map[i].bfd_reloc_val == code)
|
||||
return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup
|
||||
|
||||
static void
|
||||
rtype2howto (cache_ptr, dst)
|
||||
arelent *cache_ptr;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max);
|
||||
cache_ptr->howto = &coff_sparc_howto_table[dst->r_type];
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
cache_ptr->addend = reloc.r_offset;
|
||||
|
||||
/* Clear the r_spare field in relocs. */
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
|
||||
do { \
|
||||
dst->r_spare[0] = 0; \
|
||||
dst->r_spare[1] = 0; \
|
||||
} while (0)
|
||||
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Enable Sparc-specific hacks in coffcode.h. */
|
||||
|
||||
#define COFF_SPARC
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifndef TARGET_SYM
|
||||
#define TARGET_SYM sparccoff_vec
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_NAME
|
||||
#define TARGET_NAME "coff-sparc"
|
||||
#endif
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
@@ -1,413 +0,0 @@
|
||||
/* BFD back-end for Intel 386 COFF files (DJGPP variant with a stub).
|
||||
Copyright 1997, 1998, 1999, 2000, 2001, 2002 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file handles now also stubbed coff images. The stub is a small
|
||||
DOS executable program before the coff image to load it in memory
|
||||
and execute it. This is needed, because DOS cannot run coff files.
|
||||
|
||||
All the functions below are called by the corresponding functions
|
||||
from coffswap.h.
|
||||
The only thing what they do is to adjust the information stored in
|
||||
the COFF file which are offset into the file.
|
||||
This is needed, because DJGPP uses a very special way to load and run
|
||||
the coff image. It loads the image in memory and assumes then, that the
|
||||
image had no stub by using the filepointers as pointers in the coff
|
||||
image and NOT in the file.
|
||||
|
||||
To be compatible with any existing executables I have fixed this
|
||||
here and NOT in the DJGPP startup code. */
|
||||
|
||||
#define TARGET_SYM go32stubbedcoff_vec
|
||||
#define TARGET_NAME "coff-go32-exe"
|
||||
#define TARGET_UNDERSCORE '_'
|
||||
#define COFF_GO32_EXE
|
||||
#define COFF_LONG_SECTION_NAMES
|
||||
#define COFF_SUPPORT_GNU_LINKONCE
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#define COFF_SECTION_ALIGNMENT_ENTRIES \
|
||||
{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
/* At first the prototypes. */
|
||||
|
||||
static void
|
||||
adjust_filehdr_in_post PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_filehdr_out_pre PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_filehdr_out_post PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_scnhdr_in_post PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_scnhdr_out_pre PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_scnhdr_out_post PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_aux_in_post PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
static void
|
||||
adjust_aux_out_pre PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
static void
|
||||
adjust_aux_out_post PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
static void
|
||||
create_go32_stub PARAMS ((bfd *));
|
||||
|
||||
/* All that ..._PRE and ...POST functions are called from the corresponding
|
||||
coff_swap... functions. The ...PRE functions are called at the beginning
|
||||
of the function and the ...POST functions at the end of the swap routines. */
|
||||
|
||||
#define COFF_ADJUST_FILEHDR_IN_POST adjust_filehdr_in_post
|
||||
#define COFF_ADJUST_FILEHDR_OUT_PRE adjust_filehdr_out_pre
|
||||
#define COFF_ADJUST_FILEHDR_OUT_POST adjust_filehdr_out_post
|
||||
|
||||
#define COFF_ADJUST_SCNHDR_IN_POST adjust_scnhdr_in_post
|
||||
#define COFF_ADJUST_SCNHDR_OUT_PRE adjust_scnhdr_out_pre
|
||||
#define COFF_ADJUST_SCNHDR_OUT_POST adjust_scnhdr_out_post
|
||||
|
||||
#define COFF_ADJUST_AUX_IN_POST adjust_aux_in_post
|
||||
#define COFF_ADJUST_AUX_OUT_PRE adjust_aux_out_pre
|
||||
#define COFF_ADJUST_AUX_OUT_POST adjust_aux_out_post
|
||||
|
||||
static bfd_boolean
|
||||
go32_stubbed_coff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
|
||||
|
||||
#define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_data
|
||||
|
||||
#include "coff-i386.c"
|
||||
|
||||
/* I hold in the usrdata the stub. */
|
||||
#define bfd_coff_go32stub bfd_usrdata
|
||||
|
||||
/* This macro is used, because I cannot assume the endianess of the
|
||||
host system. */
|
||||
#define _H(index) (H_GET_16 (abfd, (header+index*2)))
|
||||
|
||||
/* These bytes are a 2048-byte DOS executable, which loads the COFF
|
||||
image into memory and then runs it. It is called 'stub'. */
|
||||
|
||||
static const unsigned char stub_bytes[STUBSIZE] =
|
||||
{
|
||||
#include "go32stub.h"
|
||||
};
|
||||
|
||||
/*
|
||||
I have not commented each swap function below, because the
|
||||
technique is in any function the same. For the ...in function,
|
||||
all the pointers are adjusted by adding STUBSIZE and for the
|
||||
...out function, it is subtracted first and after calling the
|
||||
standard swap function it is reset to the old value. */
|
||||
|
||||
/* This macro is used for adjusting the filepointers, which
|
||||
is done only, if the pointer is nonzero. */
|
||||
|
||||
#define ADJUST_VAL(val,diff) \
|
||||
if (val != 0) val += diff
|
||||
|
||||
static void
|
||||
adjust_filehdr_in_post (abfd, src, dst)
|
||||
bfd *abfd;
|
||||
PTR src;
|
||||
PTR dst;
|
||||
{
|
||||
FILHDR *filehdr_src = (FILHDR *) src;
|
||||
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
|
||||
|
||||
ADJUST_VAL (filehdr_dst->f_symptr, STUBSIZE);
|
||||
|
||||
/* Save now the stub to be used later. */
|
||||
bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
|
||||
|
||||
/* Since this function returns no status, I do not set here
|
||||
any bfd_error_...
|
||||
That means, before the use of bfd_coff_go32stub (), this value
|
||||
should be checked if it is != NULL. */
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
return;
|
||||
memcpy (bfd_coff_go32stub (abfd), filehdr_src->stub, STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_filehdr_out_pre (abfd, in, out)
|
||||
bfd *abfd;
|
||||
PTR in;
|
||||
PTR out;
|
||||
{
|
||||
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
|
||||
FILHDR *filehdr_out = (FILHDR *) out;
|
||||
|
||||
/* Generate the stub. */
|
||||
create_go32_stub (abfd);
|
||||
|
||||
/* Copy the stub to the file header. */
|
||||
if (bfd_coff_go32stub (abfd) != NULL)
|
||||
memcpy (filehdr_out->stub, bfd_coff_go32stub (abfd), STUBSIZE);
|
||||
else
|
||||
/* Use the default. */
|
||||
memcpy (filehdr_out->stub, stub_bytes, STUBSIZE);
|
||||
|
||||
ADJUST_VAL (filehdr_in->f_symptr, -STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_filehdr_out_post (abfd, in, out)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR in;
|
||||
PTR out ATTRIBUTE_UNUSED;
|
||||
{
|
||||
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
|
||||
/* Undo the above change. */
|
||||
ADJUST_VAL (filehdr_in->f_symptr, STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_scnhdr_in_post (abfd, ext, in)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR ext ATTRIBUTE_UNUSED;
|
||||
PTR in;
|
||||
{
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
|
||||
ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_scnhdr_out_pre (abfd, in, out)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR in;
|
||||
PTR out ATTRIBUTE_UNUSED;
|
||||
{
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
|
||||
ADJUST_VAL (scnhdr_int->s_scnptr, -STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_relptr, -STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_lnnoptr, -STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_scnhdr_out_post (abfd, in, out)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR in;
|
||||
PTR out ATTRIBUTE_UNUSED;
|
||||
{
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
|
||||
ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_aux_in_post (abfd, ext1, type, class, indx, numaux, in1)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR ext1 ATTRIBUTE_UNUSED;
|
||||
int type;
|
||||
int class;
|
||||
int indx ATTRIBUTE_UNUSED;
|
||||
int numaux ATTRIBUTE_UNUSED;
|
||||
PTR in1;
|
||||
{
|
||||
union internal_auxent *in = (union internal_auxent *) in1;
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_aux_out_pre (abfd, inp, type, class, indx, numaux, extp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR inp;
|
||||
int type;
|
||||
int class;
|
||||
int indx ATTRIBUTE_UNUSED;
|
||||
int numaux ATTRIBUTE_UNUSED;
|
||||
PTR extp ATTRIBUTE_UNUSED;
|
||||
{
|
||||
union internal_auxent *in = (union internal_auxent *) inp;
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -STUBSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_aux_out_post (abfd, inp, type, class, indx, numaux, extp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR inp;
|
||||
int type;
|
||||
int class;
|
||||
int indx ATTRIBUTE_UNUSED;
|
||||
int numaux ATTRIBUTE_UNUSED;
|
||||
PTR extp ATTRIBUTE_UNUSED;
|
||||
{
|
||||
union internal_auxent *in = (union internal_auxent *) inp;
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/* That's the function, which creates the stub. There are
|
||||
different cases from where the stub is taken.
|
||||
At first the environment variable $(GO32STUB) is checked and then
|
||||
$(STUB) if it was not set.
|
||||
If it exists and points to a valid stub the stub is taken from
|
||||
that file. This file can be also a whole executable file, because
|
||||
the stub is computed from the exe information at the start of that
|
||||
file.
|
||||
|
||||
If there was any error, the standard stub (compiled in this file)
|
||||
is taken. */
|
||||
|
||||
static void
|
||||
create_go32_stub (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
/* Do it only once. */
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
{
|
||||
char *stub;
|
||||
struct stat st;
|
||||
int f;
|
||||
unsigned char header[10];
|
||||
char magic[8];
|
||||
unsigned long coff_start;
|
||||
long exe_start;
|
||||
|
||||
/* Check at first the environment variable $(GO32STUB). */
|
||||
stub = getenv ("GO32STUB");
|
||||
/* Now check the environment variable $(STUB). */
|
||||
if (stub == NULL)
|
||||
stub = getenv ("STUB");
|
||||
if (stub == NULL)
|
||||
goto stub_end;
|
||||
if (stat (stub, &st) != 0)
|
||||
goto stub_end;
|
||||
#ifdef O_BINARY
|
||||
f = open (stub, O_RDONLY | O_BINARY);
|
||||
#else
|
||||
f = open (stub, O_RDONLY);
|
||||
#endif
|
||||
if (f < 0)
|
||||
goto stub_end;
|
||||
if (read (f, &header, sizeof (header)) < 0)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
if (_H (0) != 0x5a4d) /* It is not an exe file. */
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
/* Compute the size of the stub (it is every thing up
|
||||
to the beginning of the coff image). */
|
||||
coff_start = (long) _H (2) * 512L;
|
||||
if (_H (1))
|
||||
coff_start += (long) _H (1) - 512L;
|
||||
|
||||
/* Currently there is only a fixed stub size of 2048 bytes
|
||||
supported. */
|
||||
if (coff_start != 2048)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
exe_start = _H (4) * 16;
|
||||
if ((long) lseek (f, exe_start, SEEK_SET) != exe_start)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
if (read (f, &magic, 8) != 8)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
if (memcmp (magic, "go32stub", 8) != 0)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
/* Now we found a correct stub (hopefully). */
|
||||
bfd_coff_go32stub (abfd)
|
||||
= (PTR) bfd_alloc (abfd, (bfd_size_type) coff_start);
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
{
|
||||
close (f);
|
||||
return;
|
||||
}
|
||||
lseek (f, 0L, SEEK_SET);
|
||||
if ((unsigned long) read (f, bfd_coff_go32stub (abfd), coff_start)
|
||||
!= coff_start)
|
||||
{
|
||||
bfd_release (abfd, bfd_coff_go32stub (abfd));
|
||||
bfd_coff_go32stub (abfd) = NULL;
|
||||
}
|
||||
close (f);
|
||||
}
|
||||
stub_end:
|
||||
/* There was something wrong above, so use now the standard builtin
|
||||
stub. */
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
{
|
||||
bfd_coff_go32stub (abfd)
|
||||
= (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
return;
|
||||
memcpy (bfd_coff_go32stub (abfd), stub_bytes, STUBSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/* If ibfd was a stubbed coff image, copy the stub from that bfd
|
||||
to the new obfd. */
|
||||
|
||||
static bfd_boolean
|
||||
go32_stubbed_coff_bfd_copy_private_bfd_data (ibfd, obfd)
|
||||
bfd *ibfd;
|
||||
bfd *obfd;
|
||||
{
|
||||
/* Check if both are the same targets. */
|
||||
if (ibfd->xvec != obfd->xvec)
|
||||
return TRUE;
|
||||
|
||||
/* Check if both have a valid stub. */
|
||||
if (bfd_coff_go32stub (ibfd) == NULL
|
||||
|| bfd_coff_go32stub (obfd) == NULL)
|
||||
return TRUE;
|
||||
|
||||
/* Now copy the stub. */
|
||||
memcpy (bfd_coff_go32stub (obfd), bfd_coff_go32stub (ibfd), STUBSIZE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/* BFD back-end for Motorola sysv68
|
||||
Copyright 1997 Free Software Foundation, Inc.
|
||||
Written by Philippe De Muyter <phdm@info.ucl.ac.be>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68ksysvcoff_vec
|
||||
#define TARGET_NAME "coff-m68k-sysv"
|
||||
#define STATIC_RELOCS
|
||||
#define COFF_COMMON_ADDEND
|
||||
|
||||
#include "coff-m68k.c"
|
||||
210
bfd/coff-tic30.c
210
bfd/coff-tic30.c
@@ -1,210 +0,0 @@
|
||||
/* BFD back-end for TMS320C30 coff binaries.
|
||||
Copyright 1998, 1999, 2000, 2001, 2002 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/tic30.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static int coff_tic30_select_reloc PARAMS ((reloc_howto_type *));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
|
||||
reloc_howto_type * tic30_coff_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
reloc_howto_type tic30_coff_howto_table[] =
|
||||
{
|
||||
HOWTO (R_TIC30_ABS16, 2, 1, 16, FALSE, 0, 0, NULL,
|
||||
"16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
|
||||
HOWTO (R_TIC30_ABS24, 2, 2, 24, FALSE, 8, complain_overflow_bitfield, NULL,
|
||||
"24", FALSE, 0xFFFFFF00, 0xFFFFFF00, FALSE),
|
||||
HOWTO (R_TIC30_LDP, 18, 0, 24, FALSE, 0, complain_overflow_bitfield, NULL,
|
||||
"LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE),
|
||||
HOWTO (R_TIC30_ABS32, 2, 2, 32, FALSE, 0, complain_overflow_bitfield, NULL,
|
||||
"32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE),
|
||||
HOWTO (R_TIC30_PC16, 2, 1, 16, TRUE, 0, complain_overflow_signed, NULL,
|
||||
"PCREL", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
|
||||
EMPTY_HOWTO (-1)
|
||||
};
|
||||
|
||||
#ifndef coff_bfd_reloc_type_lookup
|
||||
#define coff_bfd_reloc_type_lookup tic30_coff_reloc_type_lookup
|
||||
|
||||
/* For the case statement use the code values used in tc_gen_reloc to
|
||||
map to the howto table entries that match those in both the aout
|
||||
and coff implementations. */
|
||||
|
||||
reloc_howto_type *
|
||||
tic30_coff_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_8:
|
||||
case BFD_RELOC_TIC30_LDP:
|
||||
return &tic30_coff_howto_table[2];
|
||||
case BFD_RELOC_16:
|
||||
return &tic30_coff_howto_table[0];
|
||||
case BFD_RELOC_24:
|
||||
return &tic30_coff_howto_table[1];
|
||||
case BFD_RELOC_16_PCREL:
|
||||
return &tic30_coff_howto_table[4];
|
||||
case BFD_RELOC_32:
|
||||
return &tic30_coff_howto_table[3];
|
||||
default:
|
||||
return (reloc_howto_type *) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Turn a howto into a reloc number. */
|
||||
|
||||
static int
|
||||
coff_tic30_select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
#define SELECT_RELOC(x,howto) x.r_type = coff_tic30_select_reloc(howto)
|
||||
|
||||
#define BADMAG(x) TIC30BADMAG(x)
|
||||
#define TIC30 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table. */
|
||||
|
||||
static void
|
||||
rtype2howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
switch (dst->r_type)
|
||||
{
|
||||
case R_TIC30_ABS16:
|
||||
internal->howto = &tic30_coff_howto_table[0];
|
||||
break;
|
||||
case R_TIC30_ABS24:
|
||||
internal->howto = &tic30_coff_howto_table[1];
|
||||
break;
|
||||
case R_TIC30_ABS32:
|
||||
internal->howto = &tic30_coff_howto_table[3];
|
||||
break;
|
||||
case R_TIC30_LDP:
|
||||
internal->howto = &tic30_coff_howto_table[2];
|
||||
break;
|
||||
case R_TIC30_PC16:
|
||||
internal->howto = &tic30_coff_howto_table[4];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
|
||||
|
||||
/* Perform any necessary magic to the addend in a reloc entry */
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (reloc->r_symndx > 0)
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
else
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
relent->address -= section->vma;
|
||||
}
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target tic30_coff_vec =
|
||||
{
|
||||
"coff-tic30", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
270
bfd/coff-tic4x.c
270
bfd/coff-tic4x.c
@@ -1,270 +0,0 @@
|
||||
/* BFD back-end for TMS320C4X coff binaries.
|
||||
Copyright 1996, 1997, 1998, 1999, 2000, 2002, 2003
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/tic4x.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#undef F_LSYMS
|
||||
#define F_LSYMS F_LSYMS_TICOFF
|
||||
|
||||
static bfd_boolean ticoff_bfd_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
static bfd_reloc_status_type tic4x_relocation
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char ** ));
|
||||
static reloc_howto_type *tic4x_coff_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type ));
|
||||
static void tic4x_lookup_howto
|
||||
PARAMS ((arelent *, struct internal_reloc * ));
|
||||
static reloc_howto_type *coff_tic4x_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma * ));
|
||||
static void tic4x_reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection * ));
|
||||
|
||||
|
||||
/* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local
|
||||
labels. */
|
||||
static bfd_boolean
|
||||
ticoff_bfd_is_local_label_name (abfd, name)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
const char *name;
|
||||
{
|
||||
if (TICOFF_LOCAL_LABEL_P(name))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name
|
||||
|
||||
#define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\
|
||||
tic4x_reloc_processing (RELENT,RELOC,SYMS,ABFD,SECT)
|
||||
|
||||
/* Customize coffcode.h; the default coff_ functions are set up to use
|
||||
COFF2; coff_bad_format_hook uses BADMAG, so set that for COFF2.
|
||||
The COFF1 and COFF0 vectors use custom _bad_format_hook procs
|
||||
instead of setting BADMAG. */
|
||||
#define BADMAG(x) COFF2_BADMAG(x)
|
||||
#include "coffcode.h"
|
||||
|
||||
static bfd_reloc_status_type
|
||||
tic4x_relocation (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the
|
||||
relocation to the reloc entry rather than the raw data.
|
||||
Modify the reloc inplace to reflect what we now know. */
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
reloc_howto_type tic4x_howto_table[] =
|
||||
{
|
||||
HOWTO(R_RELWORD, 0, 2, 16, FALSE, 0, complain_overflow_signed, tic4x_relocation, "RELWORD", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_REL24, 0, 2, 24, FALSE, 0, complain_overflow_bitfield, tic4x_relocation, "REL24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_dont, tic4x_relocation, "RELLONG", TRUE, 0xffffffff, 0xffffffff, FALSE),
|
||||
HOWTO(R_PCRWORD, 0, 2, 16, TRUE, 0, complain_overflow_signed, tic4x_relocation, "PCRWORD", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_PCR24, 0, 2, 24, TRUE, 0, complain_overflow_signed, tic4x_relocation, "PCR24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO(R_PARTLS16, 0, 2, 16, FALSE, 0, complain_overflow_dont, tic4x_relocation, "PARTLS16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_PARTMS8, 16, 2, 16, FALSE, 0, complain_overflow_dont, tic4x_relocation, "PARTMS8", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_RELWORD, 0, 2, 16, FALSE, 0, complain_overflow_signed, tic4x_relocation, "ARELWORD", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_REL24, 0, 2, 24, FALSE, 0, complain_overflow_signed, tic4x_relocation, "AREL24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_signed, tic4x_relocation, "ARELLONG", TRUE, 0xffffffff, 0xffffffff, FALSE),
|
||||
HOWTO(R_PCRWORD, 0, 2, 16, TRUE, 0, complain_overflow_signed, tic4x_relocation, "APCRWORD", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_PCR24, 0, 2, 24, TRUE, 0, complain_overflow_signed, tic4x_relocation, "APCR24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO(R_PARTLS16, 0, 2, 16, FALSE, 0, complain_overflow_dont, tic4x_relocation, "APARTLS16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_PARTMS8, 16, 2, 16, FALSE, 0, complain_overflow_dont, tic4x_relocation, "APARTMS8", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
};
|
||||
#define HOWTO_SIZE (sizeof(tic4x_howto_table) / sizeof(tic4x_howto_table[0]))
|
||||
|
||||
#undef coff_bfd_reloc_type_lookup
|
||||
#define coff_bfd_reloc_type_lookup tic4x_coff_reloc_type_lookup
|
||||
|
||||
/* For the case statement use the code values used tc_gen_reloc (defined in
|
||||
bfd/reloc.c) to map to the howto table entries. */
|
||||
|
||||
static reloc_howto_type *
|
||||
tic4x_coff_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
unsigned int type;
|
||||
unsigned int i;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_32: type = R_RELLONG; break;
|
||||
case BFD_RELOC_24: type = R_REL24; break;
|
||||
case BFD_RELOC_16: type = R_RELWORD; break;
|
||||
case BFD_RELOC_24_PCREL: type = R_PCR24; break;
|
||||
case BFD_RELOC_16_PCREL: type = R_PCRWORD; break;
|
||||
case BFD_RELOC_HI16: type = R_PARTMS8; break;
|
||||
case BFD_RELOC_LO16: type = R_PARTLS16; break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < HOWTO_SIZE; i++)
|
||||
{
|
||||
if (tic4x_howto_table[i].type == type)
|
||||
return tic4x_howto_table + i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table.
|
||||
Called after some initial checking by the tic4x_rtype_to_howto fn
|
||||
below. */
|
||||
static void
|
||||
tic4x_lookup_howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
unsigned int i;
|
||||
int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0;
|
||||
|
||||
for (i = 0; i < HOWTO_SIZE; i++)
|
||||
{
|
||||
if (tic4x_howto_table[i].type == dst->r_type)
|
||||
{
|
||||
internal->howto = tic4x_howto_table + i + bank;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
(*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"),
|
||||
(unsigned int) dst->r_type);
|
||||
abort();
|
||||
}
|
||||
|
||||
#undef coff_rtype_to_howto
|
||||
#define coff_rtype_to_howto coff_tic4x_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_tic4x_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment *sym ATTRIBUTE_UNUSED;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent genrel;
|
||||
|
||||
if (rel->r_symndx == -1 && addendp != NULL)
|
||||
/* This is a TI "internal relocation", which means that the relocation
|
||||
amount is the amount by which the current section is being relocated
|
||||
in the output section. */
|
||||
*addendp = (sec->output_section->vma + sec->output_offset) - sec->vma;
|
||||
|
||||
tic4x_lookup_howto (&genrel, rel);
|
||||
|
||||
return genrel.howto;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
tic4x_reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
asymbol *ptr;
|
||||
|
||||
relent->address = reloc->r_vaddr;
|
||||
|
||||
if (reloc->r_symndx != -1)
|
||||
{
|
||||
if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd))
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%s: warning: illegal symbol index %ld in relocs"),
|
||||
bfd_get_filename (abfd), reloc->r_symndx);
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = (symbols
|
||||
+ obj_convert (abfd)[reloc->r_symndx]);
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = section->symbol_ptr_ptr;
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
}
|
||||
|
||||
/* The symbols definitions that we have read in have been relocated
|
||||
as if their sections started at 0. But the offsets refering to
|
||||
the symbols in the raw data have not been modified, so we have to
|
||||
have a negative addend to compensate.
|
||||
|
||||
Note that symbols which used to be common must be left alone. */
|
||||
|
||||
/* Calculate any reloc addend by looking at the symbol. */
|
||||
CALC_ADDEND (abfd, ptr, *reloc, relent);
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* !! relent->section = (asection *) NULL; */
|
||||
|
||||
/* Fill in the relent->howto field from reloc->r_type. */
|
||||
tic4x_lookup_howto (relent, reloc);
|
||||
}
|
||||
|
||||
|
||||
/* TI COFF v0, DOS tools (little-endian headers). */
|
||||
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff0_vec, "coff0-tic4x", HAS_LOAD_PAGE, 0, '_', NULL, (PTR)&ticoff0_swap_table);
|
||||
|
||||
/* TI COFF v0, SPARC tools (big-endian headers). */
|
||||
CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff0_beh_vec, "coff0-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff0_vec, (PTR)&ticoff0_swap_table);
|
||||
|
||||
/* TI COFF v1, DOS tools (little-endian headers). */
|
||||
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff1_vec, "coff1-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff0_beh_vec, (PTR)&ticoff1_swap_table);
|
||||
|
||||
/* TI COFF v1, SPARC tools (big-endian headers). */
|
||||
CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff1_beh_vec, "coff1-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff1_vec, (PTR)&ticoff1_swap_table);
|
||||
|
||||
/* TI COFF v2, TI DOS tools output (little-endian headers). */
|
||||
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff2_vec, "coff2-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff1_beh_vec, COFF_SWAP_TABLE);
|
||||
|
||||
/* TI COFF v2, TI SPARC tools output (big-endian headers). */
|
||||
CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff2_beh_vec, "coff2-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff2_vec, COFF_SWAP_TABLE);
|
||||
@@ -1,669 +0,0 @@
|
||||
/* BFD back-end for TMS320C54X coff binaries.
|
||||
Copyright 1999, 2000, 2001, 2002, 2003, 2004
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/tic54x.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#undef F_LSYMS
|
||||
#define F_LSYMS F_LSYMS_TICOFF
|
||||
|
||||
static void tic54x_reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
static bfd_reloc_status_type tic54x_relocation
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean tic54x_set_section_contents
|
||||
PARAMS ((bfd *, sec_ptr, const PTR, file_ptr, bfd_size_type));
|
||||
static reloc_howto_type *coff_tic54x_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *));
|
||||
static bfd_boolean tic54x_set_arch_mach
|
||||
PARAMS ((bfd *, enum bfd_architecture, unsigned long));
|
||||
static reloc_howto_type * tic54x_coff_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static void tic54x_lookup_howto
|
||||
PARAMS ((arelent *, struct internal_reloc *));
|
||||
static bfd_boolean ticoff_bfd_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
|
||||
/* 32-bit operations
|
||||
The octet order is screwy. words are LSB first (LS octet, actually), but
|
||||
longwords are MSW first. For example, 0x12345678 is encoded 0x5678 in the
|
||||
first word and 0x1234 in the second. When looking at the data as stored in
|
||||
the COFF file, you would see the octets ordered as 0x78, 0x56, 0x34, 0x12.
|
||||
Don't bother with 64-bits, as there aren't any. */
|
||||
|
||||
static bfd_vma
|
||||
tic54x_getl32 (const void *p)
|
||||
{
|
||||
const bfd_byte *addr = p;
|
||||
unsigned long v;
|
||||
|
||||
v = (unsigned long) addr[2];
|
||||
v |= (unsigned long) addr[3] << 8;
|
||||
v |= (unsigned long) addr[0] << 16;
|
||||
v |= (unsigned long) addr[1] << 24;
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
tic54x_putl32 (bfd_vma data, void *p)
|
||||
{
|
||||
bfd_byte *addr = p;
|
||||
addr[2] = data & 0xff;
|
||||
addr[3] = (data >> 8) & 0xff;
|
||||
addr[0] = (data >> 16) & 0xff;
|
||||
addr[1] = (data >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static bfd_signed_vma
|
||||
tic54x_getl_signed_32 (const void *p)
|
||||
{
|
||||
const bfd_byte *addr = p;
|
||||
unsigned long v;
|
||||
|
||||
v = (unsigned long) addr[2];
|
||||
v |= (unsigned long) addr[3] << 8;
|
||||
v |= (unsigned long) addr[0] << 16;
|
||||
v |= (unsigned long) addr[1] << 24;
|
||||
#define COERCE32(x) \
|
||||
((bfd_signed_vma) (long) (((unsigned long) (x) ^ 0x80000000) - 0x80000000))
|
||||
return COERCE32 (v);
|
||||
}
|
||||
|
||||
#define coff_get_section_load_page bfd_ticoff_get_section_load_page
|
||||
#define coff_set_section_load_page bfd_ticoff_set_section_load_page
|
||||
|
||||
void
|
||||
bfd_ticoff_set_section_load_page (sect, page)
|
||||
asection *sect;
|
||||
int page;
|
||||
{
|
||||
sect->lma = (sect->lma & ADDR_MASK) | PG_TO_FLAG(page);
|
||||
}
|
||||
|
||||
int
|
||||
bfd_ticoff_get_section_load_page (sect)
|
||||
asection *sect;
|
||||
{
|
||||
int page;
|
||||
|
||||
/* Provide meaningful defaults for predefined sections. */
|
||||
if (sect == &bfd_com_section)
|
||||
page = PG_DATA;
|
||||
|
||||
else if (sect == &bfd_und_section
|
||||
|| sect == &bfd_abs_section
|
||||
|| sect == &bfd_ind_section)
|
||||
page = PG_PROG;
|
||||
|
||||
else
|
||||
page = FLAG_TO_PG (sect->lma);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
/* Set the architecture appropriately. Allow unkown architectures
|
||||
(e.g. binary). */
|
||||
|
||||
static bfd_boolean
|
||||
tic54x_set_arch_mach (abfd, arch, machine)
|
||||
bfd *abfd;
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
if (arch == bfd_arch_unknown)
|
||||
arch = bfd_arch_tic54x;
|
||||
|
||||
else if (arch != bfd_arch_tic54x)
|
||||
return FALSE;
|
||||
|
||||
return bfd_default_set_arch_mach (abfd, arch, machine);
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
tic54x_relocation (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the
|
||||
relocation to the reloc entry rather than the raw data.
|
||||
Modify the reloc inplace to reflect what we now know. */
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
reloc_howto_type tic54x_howto_table[] =
|
||||
{
|
||||
/* type,rightshift,size (0=byte, 1=short, 2=long),
|
||||
bit size, pc_relative, bitpos, dont complain_on_overflow,
|
||||
special_function, name, partial_inplace, src_mask, dst_mask, pcrel_offset. */
|
||||
|
||||
/* NORMAL BANK */
|
||||
/* 16-bit direct reference to symbol's address. */
|
||||
HOWTO (R_RELWORD,0,1,16,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"REL16",FALSE,0xFFFF,0xFFFF,FALSE),
|
||||
|
||||
/* 7 LSBs of an address */
|
||||
HOWTO (R_PARTLS7,0,1,7,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"LS7",FALSE,0x007F,0x007F,FALSE),
|
||||
|
||||
/* 9 MSBs of an address */
|
||||
/* TI assembler doesn't shift its encoding, and is thus incompatible */
|
||||
HOWTO (R_PARTMS9,7,1,9,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"MS9",FALSE,0x01FF,0x01FF,FALSE),
|
||||
|
||||
/* 23-bit relocation */
|
||||
HOWTO (R_EXTWORD,0,2,23,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"RELEXT",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
|
||||
|
||||
/* 16 bits of 23-bit extended address */
|
||||
HOWTO (R_EXTWORD16,0,1,16,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"RELEXT16",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
|
||||
|
||||
/* upper 7 bits of 23-bit extended address */
|
||||
HOWTO (R_EXTWORDMS7,16,1,7,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"RELEXTMS7",FALSE,0x7F,0x7F,FALSE),
|
||||
|
||||
/* ABSOLUTE BANK */
|
||||
/* 16-bit direct reference to symbol's address, absolute */
|
||||
HOWTO (R_RELWORD,0,1,16,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"AREL16",FALSE,0xFFFF,0xFFFF,FALSE),
|
||||
|
||||
/* 7 LSBs of an address, absolute */
|
||||
HOWTO (R_PARTLS7,0,1,7,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"ALS7",FALSE,0x007F,0x007F,FALSE),
|
||||
|
||||
/* 9 MSBs of an address, absolute */
|
||||
/* TI assembler doesn't shift its encoding, and is thus incompatible */
|
||||
HOWTO (R_PARTMS9,7,1,9,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"AMS9",FALSE,0x01FF,0x01FF,FALSE),
|
||||
|
||||
/* 23-bit direct reference, absolute */
|
||||
HOWTO (R_EXTWORD,0,2,23,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"ARELEXT",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
|
||||
|
||||
/* 16 bits of 23-bit extended address, absolute */
|
||||
HOWTO (R_EXTWORD16,0,1,16,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"ARELEXT16",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
|
||||
|
||||
/* upper 7 bits of 23-bit extended address, absolute */
|
||||
HOWTO (R_EXTWORDMS7,16,1,7,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"ARELEXTMS7",FALSE,0x7F,0x7F,FALSE),
|
||||
|
||||
/* 32-bit relocation exclusively for stabs */
|
||||
HOWTO (R_RELLONG,0,2,32,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"STAB",FALSE,0xFFFFFFFF,0xFFFFFFFF,FALSE),
|
||||
};
|
||||
|
||||
#define coff_bfd_reloc_type_lookup tic54x_coff_reloc_type_lookup
|
||||
|
||||
/* For the case statement use the code values used tc_gen_reloc (defined in
|
||||
bfd/reloc.c) to map to the howto table entries. */
|
||||
|
||||
reloc_howto_type *
|
||||
tic54x_coff_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_16:
|
||||
return &tic54x_howto_table[0];
|
||||
case BFD_RELOC_TIC54X_PARTLS7:
|
||||
return &tic54x_howto_table[1];
|
||||
case BFD_RELOC_TIC54X_PARTMS9:
|
||||
return &tic54x_howto_table[2];
|
||||
case BFD_RELOC_TIC54X_23:
|
||||
return &tic54x_howto_table[3];
|
||||
case BFD_RELOC_TIC54X_16_OF_23:
|
||||
return &tic54x_howto_table[4];
|
||||
case BFD_RELOC_TIC54X_MS7_OF_23:
|
||||
return &tic54x_howto_table[5];
|
||||
case BFD_RELOC_32:
|
||||
return &tic54x_howto_table[12];
|
||||
default:
|
||||
return (reloc_howto_type *) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table.
|
||||
Called after some initial checking by the tic54x_rtype_to_howto fn below. */
|
||||
|
||||
static void
|
||||
tic54x_lookup_howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
unsigned i;
|
||||
int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0;
|
||||
|
||||
for (i = 0; i < sizeof tic54x_howto_table/sizeof tic54x_howto_table[0]; i++)
|
||||
{
|
||||
if (tic54x_howto_table[i].type == dst->r_type)
|
||||
{
|
||||
internal->howto = tic54x_howto_table + i + bank;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
(*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"),
|
||||
(unsigned int) dst->r_type);
|
||||
abort ();
|
||||
}
|
||||
|
||||
#define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\
|
||||
tic54x_reloc_processing(RELENT,RELOC,SYMS,ABFD,SECT)
|
||||
|
||||
#define coff_rtype_to_howto coff_tic54x_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_tic54x_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment *sym ATTRIBUTE_UNUSED;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent genrel;
|
||||
|
||||
if (rel->r_symndx == -1 && addendp != NULL)
|
||||
{
|
||||
/* This is a TI "internal relocation", which means that the relocation
|
||||
amount is the amount by which the current section is being relocated
|
||||
in the output section. */
|
||||
*addendp = (sec->output_section->vma + sec->output_offset) - sec->vma;
|
||||
}
|
||||
|
||||
tic54x_lookup_howto (&genrel, rel);
|
||||
|
||||
return genrel.howto;
|
||||
}
|
||||
|
||||
/* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local
|
||||
labels. */
|
||||
|
||||
static bfd_boolean
|
||||
ticoff_bfd_is_local_label_name (abfd, name)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
const char *name;
|
||||
{
|
||||
if (TICOFF_LOCAL_LABEL_P(name))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name
|
||||
|
||||
/* 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)
|
||||
#include "coffcode.h"
|
||||
|
||||
static bfd_boolean
|
||||
tic54x_set_section_contents (abfd, section, location, offset, bytes_to_do)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
const PTR location;
|
||||
file_ptr offset;
|
||||
bfd_size_type bytes_to_do;
|
||||
{
|
||||
return coff_set_section_contents (abfd, section, location,
|
||||
offset, bytes_to_do);
|
||||
}
|
||||
|
||||
static void
|
||||
tic54x_reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
asymbol *ptr;
|
||||
|
||||
relent->address = reloc->r_vaddr;
|
||||
|
||||
if (reloc->r_symndx != -1)
|
||||
{
|
||||
if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd))
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: warning: illegal symbol index %ld in relocs"),
|
||||
abfd, reloc->r_symndx);
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = (symbols
|
||||
+ obj_convert (abfd)[reloc->r_symndx]);
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = section->symbol_ptr_ptr;
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
}
|
||||
|
||||
/* The symbols definitions that we have read in have been
|
||||
relocated as if their sections started at 0. But the offsets
|
||||
refering to the symbols in the raw data have not been
|
||||
modified, so we have to have a negative addend to compensate.
|
||||
|
||||
Note that symbols which used to be common must be left alone. */
|
||||
|
||||
/* Calculate any reloc addend by looking at the symbol. */
|
||||
CALC_ADDEND (abfd, ptr, *reloc, relent);
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* !! relent->section = (asection *) NULL;*/
|
||||
|
||||
/* Fill in the relent->howto field from reloc->r_type. */
|
||||
tic54x_lookup_howto (relent, reloc);
|
||||
}
|
||||
|
||||
/* TI COFF v0, DOS tools (little-endian headers). */
|
||||
const bfd_target tic54x_coff0_vec =
|
||||
{
|
||||
"coff0-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
NULL,
|
||||
|
||||
(PTR) & ticoff0_swap_table
|
||||
};
|
||||
|
||||
/* TI COFF v0, SPARC tools (big-endian headers). */
|
||||
const bfd_target tic54x_coff0_beh_vec =
|
||||
{
|
||||
"coff0-beh-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff0_vec,
|
||||
|
||||
(PTR) & ticoff0_swap_table
|
||||
};
|
||||
|
||||
/* TI COFF v1, DOS tools (little-endian headers). */
|
||||
const bfd_target tic54x_coff1_vec =
|
||||
{
|
||||
"coff1-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff0_beh_vec,
|
||||
|
||||
(PTR) & ticoff1_swap_table
|
||||
};
|
||||
|
||||
/* TI COFF v1, SPARC tools (big-endian headers). */
|
||||
const bfd_target tic54x_coff1_beh_vec =
|
||||
{
|
||||
"coff1-beh-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff1_vec,
|
||||
|
||||
(PTR) & ticoff1_swap_table
|
||||
};
|
||||
|
||||
/* TI COFF v2, TI DOS tools output (little-endian headers). */
|
||||
const bfd_target tic54x_coff2_vec =
|
||||
{
|
||||
"coff2-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff1_beh_vec,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
|
||||
/* TI COFF v2, TI SPARC tools output (big-endian headers). */
|
||||
const bfd_target tic54x_coff2_beh_vec =
|
||||
{
|
||||
"coff2-beh-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff2_vec,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
721
bfd/coff-tic80.c
721
bfd/coff-tic80.c
@@ -1,721 +0,0 @@
|
||||
/* BFD back-end for Texas Instruments TMS320C80 Multimedia Video Processor (MVP).
|
||||
Copyright 1996, 1997, 1999, 2000, 2001, 2002, 2003
|
||||
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 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, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/tic80.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
#define COFF_ALIGN_IN_SECTION_HEADER 1
|
||||
#define COFF_ALIGN_IN_SFLAGS 1
|
||||
|
||||
#define GET_SCNHDR_FLAGS H_GET_16
|
||||
#define PUT_SCNHDR_FLAGS H_PUT_16
|
||||
|
||||
static void rtype2howto
|
||||
PARAMS ((arelent *cache_ptr, struct internal_reloc *dst));
|
||||
static bfd_reloc_status_type ppbase_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type glob15_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type glob16_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type local16_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean coff_tic80_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static reloc_howto_type * coff_tic80_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
static reloc_howto_type tic80_howto_table[] =
|
||||
{
|
||||
|
||||
HOWTO (R_RELLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"RELLONG", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_MPPCR, /* type */
|
||||
2, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"MPPCR", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_ABS, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"ABS", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
ppbase_reloc, /* special_function */
|
||||
"PPBASE", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
ppbase_reloc, /* special_function */
|
||||
"PPLBASE", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PP15, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PP15", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PP15W, /* type */
|
||||
2, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PP15W", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PP15H, /* type */
|
||||
1, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PP15H", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PP16B, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob16_reloc, /* special_function */
|
||||
"PP16B", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x3ffc0, /* src_mask */
|
||||
0x3ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPL15, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPL15", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPL15W, /* type */
|
||||
2, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPL15W", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPL15H, /* type */
|
||||
1, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPL15H", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPL16B, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
local16_reloc, /* special_function */
|
||||
"PPL16B", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPN15, /* type */
|
||||
0, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PPN15", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPN15W, /* type */
|
||||
2, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PPN15W", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPN15H, /* type */
|
||||
1, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PPN15H", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPN16B, /* type */
|
||||
0, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob16_reloc, /* special_function */
|
||||
"PPN16B", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x3ffc0, /* src_mask */
|
||||
0x3ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLN15, /* type */
|
||||
0, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPLN15", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLN15W, /* type */
|
||||
2, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPLN15W", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLN15H, /* type */
|
||||
1, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPLN15H", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLN16B, /* type */
|
||||
0, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
local16_reloc, /* special_function */
|
||||
"PPLN16B", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Special relocation functions, used when the output file is not
|
||||
itself a COFF TIc80 file. */
|
||||
|
||||
/* This special function is used for the base address type
|
||||
relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
ppbase_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol_in ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* This special function is used for the global 15 bit relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
glob15_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol_in ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* This special function is used for the global 16 bit relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
glob16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol_in ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* This special function is used for the local 16 bit relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
local16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol_in ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* Code to turn an external r_type into a pointer to an entry in the howto_table.
|
||||
If passed an r_type we don't recognize the abort rather than silently failing
|
||||
to generate an output file. */
|
||||
|
||||
static void
|
||||
rtype2howto (cache_ptr, dst)
|
||||
arelent *cache_ptr;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof tic80_howto_table / sizeof tic80_howto_table[0]; i++)
|
||||
{
|
||||
if (tic80_howto_table[i].type == dst->r_type)
|
||||
{
|
||||
cache_ptr->howto = tic80_howto_table + i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
(*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"),
|
||||
(unsigned int) dst->r_type);
|
||||
cache_ptr->howto = tic80_howto_table + 0;
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
|
||||
#define coff_rtype_to_howto coff_tic80_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_tic80_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment *sym ATTRIBUTE_UNUSED;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent genrel;
|
||||
|
||||
if (rel -> r_symndx == -1 && addendp != NULL)
|
||||
{
|
||||
/* This is a TI "internal relocation", which means that the relocation
|
||||
amount is the amount by which the current section is being relocated
|
||||
in the output section. */
|
||||
*addendp = (sec -> output_section -> vma + sec -> output_offset) - sec -> vma;
|
||||
}
|
||||
RTYPE2HOWTO (&genrel, rel);
|
||||
return genrel.howto;
|
||||
}
|
||||
|
||||
#ifndef BADMAG
|
||||
#define BADMAG(x) TIC80BADMAG(x)
|
||||
#endif
|
||||
|
||||
#define coff_relocate_section coff_tic80_relocate_section
|
||||
|
||||
/* We need a special relocation routine to handle the PP relocs. Most
|
||||
of this is a copy of _bfd_coff_generic_relocate_section. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_tic80_relocate_section (output_bfd, info, input_bfd,
|
||||
input_section, contents, relocs, syms,
|
||||
sections)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
struct internal_reloc *rel;
|
||||
struct internal_reloc *relend;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma addend;
|
||||
bfd_vma val;
|
||||
reloc_howto_type *howto;
|
||||
bfd_reloc_status_type rstat;
|
||||
bfd_vma addr;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
h = NULL;
|
||||
sym = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
sym = syms + symndx;
|
||||
}
|
||||
|
||||
/* COFF treats common symbols in one of two ways. Either the
|
||||
size of the symbol is included in the section contents, or it
|
||||
is not. We assume that the size is not included, and force
|
||||
the rtype_to_howto function to adjust the addend as needed. */
|
||||
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
addend = - sym->n_value;
|
||||
else
|
||||
addend = 0;
|
||||
|
||||
howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
|
||||
sym, &addend);
|
||||
if (howto == NULL)
|
||||
return FALSE;
|
||||
|
||||
val = 0;
|
||||
|
||||
if (h == NULL)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
sec = bfd_abs_section_ptr;
|
||||
val = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value);
|
||||
if (! obj_pe (output_bfd))
|
||||
val -= sec->vma;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
|
||||
else if (! info->relocatable)
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma, TRUE)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
addr = rel->r_vaddr - input_section->vma;
|
||||
|
||||
/* FIXME: This code assumes little endian, but the PP can
|
||||
apparently be bi-endian. I don't know if the bi-endianness
|
||||
applies to the instruction set or just to the data. */
|
||||
switch (howto->type)
|
||||
{
|
||||
default:
|
||||
case R_ABS:
|
||||
case R_RELLONGX:
|
||||
case R_PPL15:
|
||||
case R_PPL15W:
|
||||
case R_PPL15H:
|
||||
case R_PPLN15:
|
||||
case R_PPLN15W:
|
||||
case R_PPLN15H:
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents, addr, val, addend);
|
||||
break;
|
||||
|
||||
case R_PP15:
|
||||
case R_PP15W:
|
||||
case R_PP15H:
|
||||
case R_PPN15:
|
||||
case R_PPN15W:
|
||||
case R_PPN15H:
|
||||
/* Offset the address so that we can use 4 byte relocations. */
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents + 2, addr, val, addend);
|
||||
break;
|
||||
|
||||
case R_PP16B:
|
||||
case R_PPN16B:
|
||||
{
|
||||
/* The most significant bit is stored in bit 6. */
|
||||
bfd_byte hold;
|
||||
|
||||
hold = contents[addr + 4];
|
||||
contents[addr + 4] &=~ 0x20;
|
||||
contents[addr + 4] |= (contents[addr] >> 1) & 0x20;
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents + 2, addr,
|
||||
val, addend);
|
||||
contents[addr] &=~ 0x40;
|
||||
contents[addr] |= (contents[addr + 4] << 1) & 0x40;
|
||||
contents[addr + 4] &=~ 0x20;
|
||||
contents[addr + 4] |= hold & 0x20;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_PPL16B:
|
||||
case R_PPLN16B:
|
||||
{
|
||||
/* The most significant bit is stored in bit 28. */
|
||||
bfd_byte hold;
|
||||
|
||||
hold = contents[addr + 1];
|
||||
contents[addr + 1] &=~ 0x80;
|
||||
contents[addr + 1] |= (contents[addr + 3] << 3) & 0x80;
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents, addr,
|
||||
val, addend);
|
||||
contents[addr + 3] &= ~0x10;
|
||||
contents[addr + 3] |= (contents[addr + 1] >> 3) & 0x10;
|
||||
contents[addr + 1] &=~ 0x80;
|
||||
contents[addr + 1] |= hold & 0x80;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_PPBASE:
|
||||
/* Parameter RAM is from 0x1000000 to 0x1000800. */
|
||||
contents[addr] &=~ 0x3;
|
||||
if (val >= 0x1000000 && val < 0x1000800)
|
||||
contents[addr] |= 0x3;
|
||||
else
|
||||
contents[addr] |= 0x2;
|
||||
rstat = bfd_reloc_ok;
|
||||
break;
|
||||
|
||||
case R_PPLBASE:
|
||||
/* Parameter RAM is from 0x1000000 to 0x1000800. */
|
||||
contents[addr + 2] &= ~0xc0;
|
||||
if (val >= 0x1000000 && val < 0x1000800)
|
||||
contents[addr + 2] |= 0xc0;
|
||||
else
|
||||
contents[addr + 2] |= 0x80;
|
||||
rstat = bfd_reloc_ok;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (rstat)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
case bfd_reloc_ok:
|
||||
break;
|
||||
case bfd_reloc_outofrange:
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: bad reloc address 0x%lx in section `%A'"),
|
||||
input_bfd, input_section, (unsigned long) rel->r_vaddr);
|
||||
return FALSE;
|
||||
case bfd_reloc_overflow:
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
|
||||
if (name == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto->name, (bfd_vma) 0, input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define TIC80COFF 1 /* Customize coffcode.h */
|
||||
#undef C_AUTOARG /* Clashes with TIc80's C_UEXT */
|
||||
#undef C_LASTENT /* Clashes with TIc80's C_STATLAB */
|
||||
#include "coffcode.h"
|
||||
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (tic80coff_vec, "coff-tic80", D_PAGED, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
@@ -1,35 +0,0 @@
|
||||
/* BFD back-end for Motorola 68000 COFF binaries having underscore with name.
|
||||
Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68kcoffun_vec
|
||||
#define TARGET_NAME "coff-m68k-un"
|
||||
|
||||
#define NAMES_HAVE_UNDERSCORE
|
||||
|
||||
/* define this to not have multiple copy of m68k_rtype2howto
|
||||
in the executable file */
|
||||
#define ONLY_DECLARE_RELOCS
|
||||
|
||||
/* This magic number indicates that the names have underscores.
|
||||
Other 68k magic numbers indicate that the names do not have
|
||||
underscores. */
|
||||
#define BADMAG(x) ((x).f_magic != MC68KBCSMAGIC)
|
||||
|
||||
#include "coff-m68k.c"
|
||||
383
bfd/coff-w65.c
383
bfd/coff-w65.c
@@ -1,383 +0,0 @@
|
||||
/* BFD back-end for WDC 65816 COFF binaries.
|
||||
Copyright 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/w65.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static int select_reloc PARAMS ((reloc_howto_type *));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
static int w65_reloc16_estimate PARAMS ((bfd *, asection *, arelent *, unsigned int, struct bfd_link_info *));
|
||||
static void w65_reloc16_extra_cases PARAMS ((bfd *,struct bfd_link_info *, struct bfd_link_order *, arelent *, bfd_byte *, unsigned int *, unsigned int *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
HOWTO (R_W65_ABS8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "abs8", TRUE, 0x000000ff, 0x000000ff, FALSE),
|
||||
HOWTO (R_W65_ABS16, 1, 0, 16, FALSE, 0, complain_overflow_bitfield, 0, "abs16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO (R_W65_ABS24, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "abs24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO (R_W65_ABS8S8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, ">abs8", TRUE, 0x000000ff, 0x000000ff, FALSE),
|
||||
HOWTO (R_W65_ABS8S16, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "^abs8", TRUE, 0x000000ff, 0x000000ff, FALSE),
|
||||
HOWTO (R_W65_ABS16S8, 1, 0, 16, FALSE, 0, complain_overflow_bitfield, 0, ">abs16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO (R_W65_ABS16S16,1, 0, 16, FALSE, 0, complain_overflow_bitfield, 0, "^abs16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO (R_W65_PCR8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "pcrel8", TRUE, 0x000000ff, 0x000000ff, TRUE),
|
||||
HOWTO (R_W65_PCR16, 1, 0, 16, FALSE, 0, complain_overflow_bitfield, 0, "pcrel16", TRUE, 0x0000ffff, 0x0000ffff, TRUE),
|
||||
HOWTO (R_W65_DP, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "dp", TRUE, 0x000000ff, 0x000000ff, FALSE),
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc number. */
|
||||
|
||||
#define SELECT_RELOC(x,howto) \
|
||||
{ x.r_type = select_reloc(howto); }
|
||||
|
||||
#define BADMAG(x) (W65BADMAG(x))
|
||||
#define W65 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
static int
|
||||
select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type ;
|
||||
}
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table. */
|
||||
|
||||
static void
|
||||
rtype2howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
internal->howto = howto_table + dst->r_type - 1;
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
/* Perform any necessary magic to the addend in a reloc entry. */
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent * relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol ** symbols;
|
||||
bfd * abfd;
|
||||
asection * section;
|
||||
{
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (((int) reloc->r_symndx) > 0)
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
else
|
||||
relent->sym_ptr_ptr = (asymbol **)&(bfd_abs_symbol);
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* relent->section = 0;*/
|
||||
}
|
||||
|
||||
static int
|
||||
w65_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
|
||||
bfd *abfd;
|
||||
asection *input_section;
|
||||
arelent *reloc;
|
||||
unsigned int shrink;
|
||||
struct bfd_link_info *link_info;
|
||||
{
|
||||
bfd_vma value;
|
||||
bfd_vma dot;
|
||||
bfd_vma gap;
|
||||
|
||||
/* The address of the thing to be relocated will have moved back by
|
||||
the size of the shrink - but we don't change reloc->address here,
|
||||
since we need it to know where the relocation lives in the source
|
||||
uncooked section. */
|
||||
|
||||
/* reloc->address -= shrink; conceptual */
|
||||
|
||||
bfd_vma address = reloc->address - shrink;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_MOV16B2:
|
||||
case R_JMP2:
|
||||
shrink+=2;
|
||||
break;
|
||||
|
||||
/* Thing is a move one byte. */
|
||||
case R_MOV16B1:
|
||||
value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
|
||||
if (value >= 0xff00)
|
||||
{
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16. */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one. */
|
||||
/* This will be two bytes smaller in the long run. */
|
||||
shrink += 2;
|
||||
bfd_perform_slip (abfd, 2, input_section, address);
|
||||
}
|
||||
|
||||
break;
|
||||
/* This is the 24 bit branch which could become an 8 bitter,
|
||||
the relocation points to the first byte of the insn, not the
|
||||
actual data. */
|
||||
|
||||
case R_JMPL1:
|
||||
value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to. */
|
||||
gap = value - dot;
|
||||
|
||||
if (-120 < (long) gap && (long) gap < 120)
|
||||
{
|
||||
/* Change the reloc type from 24bit, possible 8 to 8bit
|
||||
possible 32. */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* This will be two bytes smaller in the long run. */
|
||||
shrink += 2;
|
||||
bfd_perform_slip (abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_JMP1:
|
||||
value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to. */
|
||||
gap = value - (dot - shrink);
|
||||
|
||||
if (-120 < (long) gap && (long) gap < 120)
|
||||
{
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16. */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one. */
|
||||
|
||||
/* This will be two bytes smaller in the long run. */
|
||||
shrink += 2;
|
||||
bfd_perform_slip (abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return shrink;
|
||||
}
|
||||
|
||||
/* First phase of a relaxing link. */
|
||||
|
||||
/* Reloc types
|
||||
large small
|
||||
R_MOV16B1 R_MOV16B2 mov.b with 16bit or 8 bit address
|
||||
R_JMP1 R_JMP2 jmp or pcrel branch
|
||||
R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
|
||||
R_MOV24B1 R_MOV24B2 24 or 8 bit reloc for mov.b */
|
||||
|
||||
static void
|
||||
w65_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
|
||||
dst_ptr)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
unsigned int src_address = *src_ptr;
|
||||
unsigned int dst_address = *dst_ptr;
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_W65_ABS8:
|
||||
case R_W65_DP:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS8S8:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 8;
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS8S16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 16;
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
|
||||
bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
case R_W65_ABS16S8:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 8;
|
||||
bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
case R_W65_ABS16S16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 16;
|
||||
bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS24:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
|
||||
bfd_put_8 (abfd, gap >> 16, data+dst_address + 2);
|
||||
dst_address += 3;
|
||||
src_address += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_PCR8:
|
||||
{
|
||||
int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
gap -= dot + 1;
|
||||
if (gap < -128 || gap > 127)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_PCR16:
|
||||
{
|
||||
bfd_vma gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
/* This wraps within the page, so ignore the relativeness, look at the
|
||||
high part. */
|
||||
if ((gap & 0xf0000) != (dot & 0xf0000))
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
|
||||
gap -= dot + 2;
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf (_("ignoring reloc %s\n"), reloc->howto->name);
|
||||
break;
|
||||
|
||||
}
|
||||
*src_ptr = src_address;
|
||||
*dst_ptr = dst_address;
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases w65_reloc16_extra_cases
|
||||
#define coff_reloc16_estimate w65_reloc16_estimate
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (w65_vec, "coff-w65", BFD_IS_RELAXABLE, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
@@ -1,69 +0,0 @@
|
||||
/* BFD back-end for we32k COFF files.
|
||||
Copyright 1992, 1993, 1994, 1999, 2000, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Brendan Kehoe (brendan@cs.widener.edu).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/we32k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
HOWTO(R_DIR32, 0, 2, 32, FALSE, 0,complain_overflow_bitfield, 0, "dir32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
EMPTY_HOWTO (7),
|
||||
EMPTY_HOWTO (010),
|
||||
EMPTY_HOWTO (011),
|
||||
EMPTY_HOWTO (012),
|
||||
EMPTY_HOWTO (013),
|
||||
EMPTY_HOWTO (014),
|
||||
EMPTY_HOWTO (015),
|
||||
EMPTY_HOWTO (016),
|
||||
HOWTO(R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO(R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
HOWTO(R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, "DISP8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO(R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "DISP16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO(R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "DISP32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) WE32KBADMAG(x)
|
||||
#define WE32K 1
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#define coff_write_armap bsd_write_armap
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (we32kcoff_vec, "coff-we32k", 0, 0, 0, NULL, COFF_SWAP_TABLE)
|
||||
343
bfd/coff-z8k.c
343
bfd/coff-z8k.c
@@ -1,343 +0,0 @@
|
||||
/* BFD back-end for Zilog Z800n COFF binaries.
|
||||
Copyright 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Support.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "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, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0,
|
||||
"r_jr", TRUE, 0, 0, TRUE);
|
||||
|
||||
static reloc_howto_type r_disp7 =
|
||||
HOWTO (R_DISP7, 0, 0, 7, TRUE, 0, complain_overflow_bitfield, 0,
|
||||
"r_disp7", TRUE, 0, 0, TRUE);
|
||||
|
||||
static reloc_howto_type r_callr =
|
||||
HOWTO (R_CALLR, 0, 1, 12, TRUE, 0, complain_overflow_signed, 0,
|
||||
"r_callr", TRUE, 0xfff, 0xfff, TRUE);
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
static int
|
||||
coff_z8k_select_reloc (reloc_howto_type *howto)
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
#define SELECT_RELOC(x,howto) x.r_type = coff_z8k_select_reloc(howto)
|
||||
|
||||
#define BADMAG(x) Z8KBADMAG(x)
|
||||
#define Z8K 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Code to swap in the reloc. */
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table. */
|
||||
|
||||
static void
|
||||
rtype2howto (arelent *internal, struct internal_reloc *dst)
|
||||
{
|
||||
switch (dst->r_type)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
case R_IMM8:
|
||||
internal->howto = &r_imm8;
|
||||
break;
|
||||
case R_IMM16:
|
||||
internal->howto = &r_da;
|
||||
break;
|
||||
case R_JR:
|
||||
internal->howto = &r_jr;
|
||||
break;
|
||||
case R_DISP7:
|
||||
internal->howto = &r_disp7;
|
||||
break;
|
||||
case R_CALLR:
|
||||
internal->howto = &r_callr;
|
||||
break;
|
||||
case R_REL16:
|
||||
internal->howto = &r_rel16;
|
||||
break;
|
||||
case R_IMM32:
|
||||
internal->howto = &r_imm32;
|
||||
break;
|
||||
case R_IMM4L:
|
||||
internal->howto = &r_imm4l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
|
||||
|
||||
/* 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 = (link_order->offset
|
||||
+ *dst_ptr
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 1; /* -1, since we're in the odd byte of the
|
||||
word and the pc's been incremented. */
|
||||
|
||||
if (gap & 1)
|
||||
abort ();
|
||||
gap /= 2;
|
||||
if (gap > 128 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_8 (in_abfd, gap, data + *dst_ptr);
|
||||
(*dst_ptr)++;
|
||||
(*src_ptr)++;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_DISP7:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = (link_order->offset
|
||||
+ *dst_ptr
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 1; /* -1, since we're in the odd byte of the
|
||||
word and the pc's been incremented. */
|
||||
|
||||
if (gap & 1)
|
||||
abort ();
|
||||
gap /= 2;
|
||||
|
||||
if (gap > 0 || gap < -127)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_8 (in_abfd,
|
||||
(bfd_get_8 ( in_abfd, data + *dst_ptr) & 0x80) + (-gap & 0x7f),
|
||||
data + *dst_ptr);
|
||||
(*dst_ptr)++;
|
||||
(*src_ptr)++;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_CALLR:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = (link_order->offset
|
||||
+ *dst_ptr
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 2;
|
||||
|
||||
if (gap & 1)
|
||||
abort ();
|
||||
if (gap > 4096 || gap < -4095)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
gap /= 2;
|
||||
bfd_put_16 (in_abfd,
|
||||
(bfd_get_16 ( in_abfd, data + *dst_ptr) & 0xf000) | (-gap & 0x0fff),
|
||||
data + *dst_ptr);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_REL16:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = (link_order->offset
|
||||
+ *dst_ptr
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 2;
|
||||
|
||||
if (gap > 32767 || gap < -32768)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_16 (in_abfd, (bfd_vma) gap, data + *dst_ptr);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases extra_case
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (z8kcoff_vec, "coff-z8k", 0, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
3004
bfd/coff64-rs6000.c
3004
bfd/coff64-rs6000.c
File diff suppressed because it is too large
Load Diff
5744
bfd/coffcode.h
5744
bfd/coffcode.h
File diff suppressed because it is too large
Load Diff
2506
bfd/coffgen.c
2506
bfd/coffgen.c
File diff suppressed because it is too large
Load Diff
3035
bfd/cofflink.c
3035
bfd/cofflink.c
File diff suppressed because it is too large
Load Diff
906
bfd/coffswap.h
906
bfd/coffswap.h
@@ -1,906 +0,0 @@
|
||||
/* Generic COFF swapping routines, for BFD.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000,
|
||||
2001, 2002
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file contains routines used to swap COFF data. It is a header
|
||||
file because the details of swapping depend on the details of the
|
||||
structures used by each COFF implementation. This is included by
|
||||
coffcode.h, as well as by the ECOFF backend.
|
||||
|
||||
Any file which uses this must first include "coff/internal.h" and
|
||||
"coff/CPU.h". The functions will then be correct for that CPU. */
|
||||
|
||||
#ifndef 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
|
||||
|
||||
static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
|
||||
static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
|
||||
static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
|
||||
static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
|
||||
static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
|
||||
static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR));
|
||||
#ifndef NO_COFF_RELOCS
|
||||
static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
|
||||
static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
|
||||
#endif /* NO_COFF_RELOCS */
|
||||
#ifndef NO_COFF_SYMBOLS
|
||||
static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
|
||||
static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
|
||||
static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
static unsigned int coff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
#endif /* NO_COFF_SYMBOLS */
|
||||
#ifndef NO_COFF_LINENOS
|
||||
static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
|
||||
static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
|
||||
#endif /* NO_COFF_LINENOS */
|
||||
|
||||
#ifndef NO_COFF_RELOCS
|
||||
|
||||
static void
|
||||
coff_swap_reloc_in (abfd, src, dst)
|
||||
bfd *abfd;
|
||||
PTR src;
|
||||
PTR dst;
|
||||
{
|
||||
RELOC *reloc_src = (RELOC *) src;
|
||||
struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
|
||||
|
||||
reloc_dst->r_vaddr = 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 (abfd, src, dst)
|
||||
bfd *abfd;
|
||||
PTR src;
|
||||
PTR dst;
|
||||
{
|
||||
struct internal_reloc *reloc_src = (struct internal_reloc *) src;
|
||||
struct external_reloc *reloc_dst = (struct external_reloc *) dst;
|
||||
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 (abfd, src, dst)
|
||||
bfd *abfd;
|
||||
PTR src;
|
||||
PTR 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 (abfd, in, out)
|
||||
bfd *abfd;
|
||||
PTR in;
|
||||
PTR 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 (abfd, ext1, in1)
|
||||
bfd *abfd;
|
||||
PTR ext1;
|
||||
PTR in1;
|
||||
{
|
||||
SYMENT *ext = (SYMENT *) ext1;
|
||||
struct internal_syment *in = (struct internal_syment *) in1;
|
||||
|
||||
if (ext->e.e_name[0] == 0)
|
||||
{
|
||||
in->_n._n_n._n_zeroes = 0;
|
||||
in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if SYMNMLEN != E_SYMNMLEN
|
||||
-> Error, we need to cope with truncating or extending SYMNMLEN!;
|
||||
#else
|
||||
memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
|
||||
#endif
|
||||
}
|
||||
in->n_value = H_GET_32 (abfd, ext->e_value);
|
||||
in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
|
||||
if (sizeof (ext->e_type) == 2)
|
||||
{
|
||||
in->n_type = H_GET_16 (abfd, ext->e_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
in->n_type = H_GET_32 (abfd, ext->e_type);
|
||||
}
|
||||
in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
|
||||
in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
|
||||
#ifdef COFF_ADJUST_SYM_IN_POST
|
||||
COFF_ADJUST_SYM_IN_POST (abfd, ext1, in1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_sym_out (abfd, inp, extp)
|
||||
bfd *abfd;
|
||||
PTR inp;
|
||||
PTR 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 (abfd, ext1, type, class, indx, numaux, in1)
|
||||
bfd *abfd;
|
||||
PTR ext1;
|
||||
int type;
|
||||
int class;
|
||||
int indx;
|
||||
int numaux;
|
||||
PTR in1;
|
||||
{
|
||||
AUXENT *ext = (AUXENT *) ext1;
|
||||
union internal_auxent *in = (union internal_auxent *) in1;
|
||||
|
||||
#ifdef COFF_ADJUST_AUX_IN_PRE
|
||||
COFF_ADJUST_AUX_IN_PRE (abfd, ext1, type, class, indx, numaux, in1);
|
||||
#endif
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case C_FILE:
|
||||
if (ext->x_file.x_fname[0] == 0)
|
||||
{
|
||||
in->x_file.x_n.x_zeroes = 0;
|
||||
in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if FILNMLEN != E_FILNMLEN
|
||||
-> Error, we need to cope with truncating or extending FILNMLEN!;
|
||||
#else
|
||||
if (numaux > 1)
|
||||
{
|
||||
if (indx == 0)
|
||||
memcpy (in->x_file.x_fname, ext->x_file.x_fname,
|
||||
numaux * sizeof (AUXENT));
|
||||
}
|
||||
else
|
||||
memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
|
||||
#endif
|
||||
}
|
||||
goto end;
|
||||
|
||||
case C_STAT:
|
||||
#ifdef C_LEAFSTAT
|
||||
case C_LEAFSTAT:
|
||||
#endif
|
||||
case C_HIDDEN:
|
||||
if (type == T_NULL)
|
||||
{
|
||||
in->x_scn.x_scnlen = GET_SCN_SCNLEN (abfd, ext);
|
||||
in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext);
|
||||
in->x_scn.x_nlinno = GET_SCN_NLINNO (abfd, ext);
|
||||
|
||||
/* PE defines some extra fields; we zero them out for
|
||||
safety. */
|
||||
in->x_scn.x_checksum = 0;
|
||||
in->x_scn.x_associated = 0;
|
||||
in->x_scn.x_comdat = 0;
|
||||
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
|
||||
#ifndef NO_TVNDX
|
||||
in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
|
||||
#endif
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
|
||||
in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DIMNUM != E_DIMNUM
|
||||
#error we need to cope with truncating or extending DIMNUM
|
||||
#endif
|
||||
in->x_sym.x_fcnary.x_ary.x_dimen[0] =
|
||||
H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
||||
in->x_sym.x_fcnary.x_ary.x_dimen[1] =
|
||||
H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
||||
in->x_sym.x_fcnary.x_ary.x_dimen[2] =
|
||||
H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
||||
in->x_sym.x_fcnary.x_ary.x_dimen[3] =
|
||||
H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
||||
}
|
||||
|
||||
if (ISFCN (type))
|
||||
{
|
||||
in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO (abfd, ext);
|
||||
in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE (abfd, ext);
|
||||
}
|
||||
|
||||
end: ;
|
||||
|
||||
#ifdef COFF_ADJUST_AUX_IN_POST
|
||||
COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
|
||||
bfd *abfd;
|
||||
PTR inp;
|
||||
int type;
|
||||
int class;
|
||||
int indx ATTRIBUTE_UNUSED;
|
||||
int numaux ATTRIBUTE_UNUSED;
|
||||
PTR extp;
|
||||
{
|
||||
union internal_auxent *in = (union internal_auxent *) inp;
|
||||
AUXENT *ext = (AUXENT *) extp;
|
||||
|
||||
#ifdef COFF_ADJUST_AUX_OUT_PRE
|
||||
COFF_ADJUST_AUX_OUT_PRE (abfd, inp, type, class, indx, numaux, extp);
|
||||
#endif
|
||||
|
||||
memset ((PTR)ext, 0, AUXESZ);
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case C_FILE:
|
||||
if (in->x_file.x_fname[0] == 0)
|
||||
{
|
||||
H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
|
||||
H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if FILNMLEN != E_FILNMLEN
|
||||
-> Error, we need to cope with truncating or extending FILNMLEN!;
|
||||
#else
|
||||
memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
|
||||
#endif
|
||||
}
|
||||
goto end;
|
||||
|
||||
case C_STAT:
|
||||
#ifdef C_LEAFSTAT
|
||||
case C_LEAFSTAT:
|
||||
#endif
|
||||
case C_HIDDEN:
|
||||
if (type == T_NULL)
|
||||
{
|
||||
PUT_SCN_SCNLEN (abfd, in->x_scn.x_scnlen, ext);
|
||||
PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext);
|
||||
PUT_SCN_NLINNO (abfd, in->x_scn.x_nlinno, ext);
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
|
||||
#ifndef NO_TVNDX
|
||||
H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
|
||||
#endif
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
PUT_FCN_LNNOPTR (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
|
||||
PUT_FCN_ENDNDX (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DIMNUM != E_DIMNUM
|
||||
#error we need to cope with truncating or extending DIMNUM
|
||||
#endif
|
||||
H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
|
||||
ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
||||
H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
|
||||
ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
||||
H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
|
||||
ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
||||
H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
|
||||
ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
||||
}
|
||||
|
||||
if (ISFCN (type))
|
||||
H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
|
||||
else
|
||||
{
|
||||
PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
|
||||
PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
|
||||
}
|
||||
|
||||
end:
|
||||
#ifdef COFF_ADJUST_AUX_OUT_POST
|
||||
COFF_ADJUST_AUX_OUT_POST (abfd, inp, type, class, indx, numaux, extp);
|
||||
#endif
|
||||
return AUXESZ;
|
||||
}
|
||||
|
||||
#endif /* NO_COFF_SYMBOLS */
|
||||
|
||||
#ifndef NO_COFF_LINENOS
|
||||
|
||||
static void
|
||||
coff_swap_lineno_in (abfd, ext1, in1)
|
||||
bfd *abfd;
|
||||
PTR ext1;
|
||||
PTR in1;
|
||||
{
|
||||
LINENO *ext = (LINENO *) ext1;
|
||||
struct internal_lineno *in = (struct internal_lineno *) in1;
|
||||
|
||||
in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
|
||||
in->l_lnno = GET_LINENO_LNNO (abfd, ext);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_lineno_out (abfd, inp, outp)
|
||||
bfd *abfd;
|
||||
PTR inp;
|
||||
PTR outp;
|
||||
{
|
||||
struct internal_lineno *in = (struct internal_lineno *) inp;
|
||||
struct external_lineno *ext = (struct external_lineno *) outp;
|
||||
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 (abfd, aouthdr_ext1, aouthdr_int1)
|
||||
bfd *abfd;
|
||||
PTR aouthdr_ext1;
|
||||
PTR aouthdr_int1;
|
||||
{
|
||||
AOUTHDR *aouthdr_ext;
|
||||
struct internal_aouthdr *aouthdr_int;
|
||||
|
||||
aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
|
||||
aouthdr_int = (struct internal_aouthdr *) aouthdr_int1;
|
||||
aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic);
|
||||
aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp);
|
||||
aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize);
|
||||
aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize);
|
||||
aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize);
|
||||
aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry);
|
||||
aouthdr_int->text_start =
|
||||
GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start);
|
||||
aouthdr_int->data_start =
|
||||
GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start);
|
||||
|
||||
#ifdef I960
|
||||
aouthdr_int->tagentries = H_GET_32 (abfd, aouthdr_ext->tagentries);
|
||||
#endif
|
||||
|
||||
#ifdef APOLLO_M68
|
||||
H_PUT_32 (abfd, aouthdr_int->o_inlib, aouthdr_ext->o_inlib);
|
||||
H_PUT_32 (abfd, aouthdr_int->o_sri, aouthdr_ext->o_sri);
|
||||
H_PUT_32 (abfd, aouthdr_int->vid[0], aouthdr_ext->vid);
|
||||
H_PUT_32 (abfd, aouthdr_int->vid[1], aouthdr_ext->vid + 4);
|
||||
#endif
|
||||
|
||||
#ifdef RS6000COFF_C
|
||||
#ifdef XCOFF64
|
||||
aouthdr_int->o_toc = H_GET_64 (abfd, aouthdr_ext->o_toc);
|
||||
#else
|
||||
aouthdr_int->o_toc = H_GET_32 (abfd, aouthdr_ext->o_toc);
|
||||
#endif
|
||||
aouthdr_int->o_snentry = H_GET_16 (abfd, aouthdr_ext->o_snentry);
|
||||
aouthdr_int->o_sntext = H_GET_16 (abfd, aouthdr_ext->o_sntext);
|
||||
aouthdr_int->o_sndata = H_GET_16 (abfd, aouthdr_ext->o_sndata);
|
||||
aouthdr_int->o_sntoc = H_GET_16 (abfd, aouthdr_ext->o_sntoc);
|
||||
aouthdr_int->o_snloader = H_GET_16 (abfd, aouthdr_ext->o_snloader);
|
||||
aouthdr_int->o_snbss = H_GET_16 (abfd, aouthdr_ext->o_snbss);
|
||||
aouthdr_int->o_algntext = H_GET_16 (abfd, aouthdr_ext->o_algntext);
|
||||
aouthdr_int->o_algndata = H_GET_16 (abfd, aouthdr_ext->o_algndata);
|
||||
aouthdr_int->o_modtype = H_GET_16 (abfd, aouthdr_ext->o_modtype);
|
||||
aouthdr_int->o_cputype = H_GET_16 (abfd, aouthdr_ext->o_cputype);
|
||||
#ifdef XCOFF64
|
||||
aouthdr_int->o_maxstack = H_GET_64 (abfd, aouthdr_ext->o_maxstack);
|
||||
aouthdr_int->o_maxdata = H_GET_64 (abfd, aouthdr_ext->o_maxdata);
|
||||
#else
|
||||
aouthdr_int->o_maxstack = H_GET_32 (abfd, aouthdr_ext->o_maxstack);
|
||||
aouthdr_int->o_maxdata = H_GET_32 (abfd, aouthdr_ext->o_maxdata);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MIPSECOFF
|
||||
aouthdr_int->bss_start = H_GET_32 (abfd, aouthdr_ext->bss_start);
|
||||
aouthdr_int->gp_value = H_GET_32 (abfd, aouthdr_ext->gp_value);
|
||||
aouthdr_int->gprmask = H_GET_32 (abfd, aouthdr_ext->gprmask);
|
||||
aouthdr_int->cprmask[0] = H_GET_32 (abfd, aouthdr_ext->cprmask[0]);
|
||||
aouthdr_int->cprmask[1] = H_GET_32 (abfd, aouthdr_ext->cprmask[1]);
|
||||
aouthdr_int->cprmask[2] = H_GET_32 (abfd, aouthdr_ext->cprmask[2]);
|
||||
aouthdr_int->cprmask[3] = H_GET_32 (abfd, aouthdr_ext->cprmask[3]);
|
||||
#endif
|
||||
|
||||
#ifdef ALPHAECOFF
|
||||
aouthdr_int->bss_start = H_GET_64 (abfd, aouthdr_ext->bss_start);
|
||||
aouthdr_int->gp_value = H_GET_64 (abfd, aouthdr_ext->gp_value);
|
||||
aouthdr_int->gprmask = H_GET_32 (abfd, aouthdr_ext->gprmask);
|
||||
aouthdr_int->fprmask = H_GET_32 (abfd, aouthdr_ext->fprmask);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_aouthdr_out (abfd, in, out)
|
||||
bfd *abfd;
|
||||
PTR in;
|
||||
PTR out;
|
||||
{
|
||||
struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *) in;
|
||||
AOUTHDR *aouthdr_out = (AOUTHDR *) out;
|
||||
|
||||
H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->magic);
|
||||
H_PUT_16 (abfd, aouthdr_in->vstamp, aouthdr_out->vstamp);
|
||||
PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->tsize);
|
||||
PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->dsize);
|
||||
PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->bsize);
|
||||
PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->entry);
|
||||
PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
|
||||
aouthdr_out->text_start);
|
||||
PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
|
||||
aouthdr_out->data_start);
|
||||
|
||||
#ifdef I960
|
||||
H_PUT_32 (abfd, aouthdr_in->tagentries, aouthdr_out->tagentries);
|
||||
#endif
|
||||
|
||||
#ifdef RS6000COFF_C
|
||||
#ifdef XCOFF64
|
||||
H_PUT_64 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
|
||||
#else
|
||||
H_PUT_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
|
||||
#endif
|
||||
H_PUT_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
|
||||
#ifdef XCOFF64
|
||||
H_PUT_64 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
|
||||
H_PUT_64 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
|
||||
#else
|
||||
H_PUT_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
|
||||
H_PUT_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
|
||||
#endif
|
||||
memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
|
||||
#ifdef XCOFF64
|
||||
memset (aouthdr_out->o_debugger, 0, sizeof aouthdr_out->o_debugger);
|
||||
memset (aouthdr_out->o_resv3, 0, sizeof aouthdr_out->o_resv3);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MIPSECOFF
|
||||
H_PUT_32 (abfd, aouthdr_in->bss_start, aouthdr_out->bss_start);
|
||||
H_PUT_32 (abfd, aouthdr_in->gp_value, aouthdr_out->gp_value);
|
||||
H_PUT_32 (abfd, aouthdr_in->gprmask, aouthdr_out->gprmask);
|
||||
H_PUT_32 (abfd, aouthdr_in->cprmask[0], aouthdr_out->cprmask[0]);
|
||||
H_PUT_32 (abfd, aouthdr_in->cprmask[1], aouthdr_out->cprmask[1]);
|
||||
H_PUT_32 (abfd, aouthdr_in->cprmask[2], aouthdr_out->cprmask[2]);
|
||||
H_PUT_32 (abfd, aouthdr_in->cprmask[3], aouthdr_out->cprmask[3]);
|
||||
#endif
|
||||
|
||||
#ifdef ALPHAECOFF
|
||||
/* FIXME: What does bldrev mean? */
|
||||
H_PUT_16 (abfd, 2, aouthdr_out->bldrev);
|
||||
H_PUT_16 (abfd, 0, aouthdr_out->padding);
|
||||
H_PUT_64 (abfd, aouthdr_in->bss_start, aouthdr_out->bss_start);
|
||||
H_PUT_64 (abfd, aouthdr_in->gp_value, aouthdr_out->gp_value);
|
||||
H_PUT_32 (abfd, aouthdr_in->gprmask, aouthdr_out->gprmask);
|
||||
H_PUT_32 (abfd, aouthdr_in->fprmask, aouthdr_out->fprmask);
|
||||
#endif
|
||||
|
||||
return AOUTSZ;
|
||||
}
|
||||
|
||||
static void
|
||||
coff_swap_scnhdr_in (abfd, ext, in)
|
||||
bfd *abfd;
|
||||
PTR ext;
|
||||
PTR in;
|
||||
{
|
||||
SCNHDR *scnhdr_ext = (SCNHDR *) ext;
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
|
||||
#ifdef COFF_ADJUST_SCNHDR_IN_PRE
|
||||
COFF_ADJUST_SCNHDR_IN_PRE (abfd, ext, in);
|
||||
#endif
|
||||
memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name));
|
||||
|
||||
scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr);
|
||||
scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr);
|
||||
scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size);
|
||||
|
||||
scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr);
|
||||
scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr);
|
||||
scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr);
|
||||
scnhdr_int->s_flags = GET_SCNHDR_FLAGS (abfd, scnhdr_ext->s_flags);
|
||||
scnhdr_int->s_nreloc = GET_SCNHDR_NRELOC (abfd, scnhdr_ext->s_nreloc);
|
||||
scnhdr_int->s_nlnno = GET_SCNHDR_NLNNO (abfd, scnhdr_ext->s_nlnno);
|
||||
#ifdef I960
|
||||
scnhdr_int->s_align = GET_SCNHDR_ALIGN (abfd, scnhdr_ext->s_align);
|
||||
#endif
|
||||
#ifdef COFF_ADJUST_SCNHDR_IN_POST
|
||||
COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_scnhdr_out (abfd, in, out)
|
||||
bfd *abfd;
|
||||
PTR in;
|
||||
PTR out;
|
||||
{
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
SCNHDR *scnhdr_ext = (SCNHDR *) out;
|
||||
unsigned int ret = bfd_coff_scnhsz (abfd);
|
||||
|
||||
#ifdef COFF_ADJUST_SCNHDR_OUT_PRE
|
||||
COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out);
|
||||
#endif
|
||||
memcpy (scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
|
||||
|
||||
PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr);
|
||||
PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr);
|
||||
PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size, scnhdr_ext->s_size);
|
||||
PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr);
|
||||
PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr);
|
||||
PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr);
|
||||
PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
|
||||
#if defined(M88)
|
||||
H_PUT_32 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
|
||||
H_PUT_32 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
|
||||
#else
|
||||
if (scnhdr_int->s_nlnno <= MAX_SCNHDR_NLNNO)
|
||||
PUT_SCNHDR_NLNNO (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
|
||||
else
|
||||
{
|
||||
char buf[sizeof (scnhdr_int->s_name) + 1];
|
||||
|
||||
memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
|
||||
buf[sizeof (scnhdr_int->s_name)] = '\0';
|
||||
(*_bfd_error_handler)
|
||||
(_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
|
||||
bfd_get_filename (abfd),
|
||||
buf, scnhdr_int->s_nlnno);
|
||||
PUT_SCNHDR_NLNNO (abfd, 0xffff, scnhdr_ext->s_nlnno);
|
||||
}
|
||||
|
||||
if (scnhdr_int->s_nreloc <= MAX_SCNHDR_NRELOC)
|
||||
PUT_SCNHDR_NRELOC (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
|
||||
else
|
||||
{
|
||||
char buf[sizeof (scnhdr_int->s_name) + 1];
|
||||
|
||||
memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
|
||||
buf[sizeof (scnhdr_int->s_name)] = '\0';
|
||||
(*_bfd_error_handler) (_("%s: %s: reloc overflow: 0x%lx > 0xffff"),
|
||||
bfd_get_filename (abfd),
|
||||
buf, scnhdr_int->s_nreloc);
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
PUT_SCNHDR_NRELOC (abfd, 0xffff, scnhdr_ext->s_nreloc);
|
||||
ret = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef I960
|
||||
PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, scnhdr_ext->s_align);
|
||||
#endif
|
||||
#ifdef COFF_ADJUST_SCNHDR_OUT_POST
|
||||
COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
1384
bfd/config.bfd
1384
bfd/config.bfd
File diff suppressed because it is too large
Load Diff
321
bfd/config.in
321
bfd/config.in
@@ -1,321 +0,0 @@
|
||||
/* config.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define to 1 if NLS is requested */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define to 1 if you have the <argz.h> header file. */
|
||||
#undef HAVE_ARGZ_H
|
||||
|
||||
/* Define to 1 if you have the `dcgettext' function. */
|
||||
#undef HAVE_DCGETTEXT
|
||||
|
||||
/* 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 `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 `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 `getcwd' function. */
|
||||
#undef HAVE_GETCWD
|
||||
|
||||
/* 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 as 1 if you have gettext and don't want to use GNU gettext. */
|
||||
#undef HAVE_GETTEXT
|
||||
|
||||
/* Define to 1 if you have the `getuid' function. */
|
||||
#undef HAVE_GETUID
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define if your locale.h file contains LC_MESSAGES. */
|
||||
#undef HAVE_LC_MESSAGES
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* 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_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 <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* 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 `munmap' function. */
|
||||
#undef HAVE_MUNMAP
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <nl_types.h> header file. */
|
||||
#undef HAVE_NL_TYPES_H
|
||||
|
||||
/* Define if <sys/procfs.h> has prpsinfo32_t. */
|
||||
#undef HAVE_PRPSINFO32_T
|
||||
|
||||
/* Define if <sys/procfs.h> has prpsinfo_t. */
|
||||
#undef HAVE_PRPSINFO_T
|
||||
|
||||
/* 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 psinfo_t. */
|
||||
#undef HAVE_PSINFO_T
|
||||
|
||||
/* 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 to 1 if you have the `putenv' function. */
|
||||
#undef HAVE_PUTENV
|
||||
|
||||
/* Define if <sys/procfs.h> has pxstatus_t. */
|
||||
#undef HAVE_PXSTATUS_T
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define to 1 if you have the `setitimer' function. */
|
||||
#undef HAVE_SETITIMER
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* 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 if you have the stpcpy function */
|
||||
#undef HAVE_STPCPY
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* 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/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 <values.h> header file. */
|
||||
#undef HAVE_VALUES_H
|
||||
|
||||
/* Define if <sys/procfs.h> has win32_pstatus_t. */
|
||||
#undef HAVE_WIN32_PSTATUS_T
|
||||
|
||||
/* Define to 1 if you have the `__argz_count' function. */
|
||||
#undef HAVE___ARGZ_COUNT
|
||||
|
||||
/* Define to 1 if you have the `__argz_next' function. */
|
||||
#undef HAVE___ARGZ_NEXT
|
||||
|
||||
/* Define to 1 if you have the `__argz_stringify' function. */
|
||||
#undef HAVE___ARGZ_STRINGIFY
|
||||
|
||||
/* Define if free is not declared in system header files. */
|
||||
#undef NEED_DECLARATION_FREE
|
||||
|
||||
/* Define if getenv is not declared in system header files. */
|
||||
#undef NEED_DECLARATION_GETENV
|
||||
|
||||
/* Define if malloc is not declared in system header files. */
|
||||
#undef NEED_DECLARATION_MALLOC
|
||||
|
||||
/* Define if realloc is not declared in system header files. */
|
||||
#undef NEED_DECLARATION_REALLOC
|
||||
|
||||
/* Define if strstr is not declared in system header files. */
|
||||
#undef NEED_DECLARATION_STRSTR
|
||||
|
||||
/* 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 version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* The number of bytes in type long */
|
||||
#undef SIZEOF_LONG
|
||||
|
||||
/* The number of bytes in type long long */
|
||||
#undef SIZEOF_LONG_LONG
|
||||
|
||||
/* The number of bytes in type off_t */
|
||||
#undef SIZEOF_OFF_T
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* 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
|
||||
|
||||
/* Use b modifier when opening binary files? */
|
||||
#undef USE_BINARY_FOPEN
|
||||
|
||||
/* Use mmap if it's available? */
|
||||
#undef USE_MMAP
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
/* Define to `long' if <sys/types.h> does not define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
14114
bfd/configure
vendored
14114
bfd/configure
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,215 +0,0 @@
|
||||
$!
|
||||
$! This file configures the bfd library for use with openVMS (Alpha and Vax)
|
||||
$!
|
||||
$! We do not use the configure script, since we do not have /bin/sh
|
||||
$! to execute it.
|
||||
$!
|
||||
$! Written by Klaus K"ampf (kkaempf@rmi.de)
|
||||
$!
|
||||
$arch_indx = 1 + ((f$getsyi("CPU").ge.128).and.1) ! vax==1, alpha==2
|
||||
$arch = f$element(arch_indx,"|","|VAX|Alpha|")
|
||||
$!
|
||||
$if arch .eqs. "Alpha"
|
||||
$then
|
||||
$ write sys$output "Configuring for Alpha target"
|
||||
$ target = "alpha"
|
||||
$!
|
||||
$! copy bfd-in2.h to bfd.h, replacing @ macros
|
||||
$!
|
||||
$ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
|
||||
[]bfd-in2.h /output=[]bfd.h
|
||||
$DECK
|
||||
!
|
||||
! Copy file, changing lines with macros (@@)
|
||||
!
|
||||
!
|
||||
vfile := CREATE_BUFFER("vfile", "CONFIGURE.IN");
|
||||
rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
|
||||
match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
vers := CURRENT_LINE-")";
|
||||
ELSE;
|
||||
vers := "unknown";
|
||||
ENDIF;
|
||||
|
||||
file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
|
||||
rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
|
||||
|
||||
match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT(vers);
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('64');
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@BFD_HOST_64BIT_LONG@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('0');
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT_DEFINED@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('__DECC');
|
||||
SPLIT_LINE;
|
||||
COPY_TEXT('#include <ints.h>');
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('int64');
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@BFD_HOST_U_64_BIT@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('uint64');
|
||||
ENDIF;
|
||||
WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
|
||||
QUIT
|
||||
$ EOD
|
||||
$
|
||||
$else
|
||||
$
|
||||
$ write sys$output "Configuring for Vax target"
|
||||
$ target = "vax"
|
||||
$!
|
||||
$! copy bfd-in2.h to bfd.h, replacing @ macros
|
||||
$!
|
||||
$ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
|
||||
[]bfd-in2.h /output=[]bfd.h
|
||||
$DECK
|
||||
!
|
||||
! Copy file, changing lines with macros (@@)
|
||||
!
|
||||
!
|
||||
vfile := CREATE_BUFFER("vfile", "CONFIGURE.IN");
|
||||
rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
|
||||
match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
vers := CURRENT_LINE-")";
|
||||
ELSE;
|
||||
vers := "unknown";
|
||||
ENDIF;
|
||||
|
||||
file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
|
||||
rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
|
||||
|
||||
match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT(vers);
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('32');
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@BFD_HOST_64BIT_LONG@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('0');
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT_DEFINED@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('__DECC');
|
||||
SPLIT_LINE;
|
||||
COPY_TEXT('#include <ints.h>');
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('int64');
|
||||
ENDIF;
|
||||
match_pos := SEARCH_QUIETLY('@BFD_HOST_U_64_BIT@', FORWARD, EXACT, rang);
|
||||
IF match_pos <> 0 THEN;
|
||||
POSITION(BEGINNING_OF(match_pos));
|
||||
ERASE(match_pos);
|
||||
COPY_TEXT('uint64');
|
||||
ENDIF;
|
||||
WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
|
||||
QUIT
|
||||
$ EOD
|
||||
$endif
|
||||
$
|
||||
$ write sys$output "Generated `bfd.h' from `bfd-in2.h'."
|
||||
$!
|
||||
$!
|
||||
$! create targmatch.h
|
||||
$!
|
||||
$ open/write tfile []targmatch.h
|
||||
$ write tfile "{ """ + target + "-*-*vms*""" + ","
|
||||
$ write tfile "#if defined (SELECT_VECS)"
|
||||
$ write tfile "SELECT_VECS"
|
||||
$ write tfile "#else"
|
||||
$ write tfile "UNSUPPORTED_TARGET"
|
||||
$ write tfile "#endif"
|
||||
$ write tfile "},"
|
||||
$ close tfile
|
||||
$ write sys$output "Generated `targmatch.h'"
|
||||
$!
|
||||
$!
|
||||
$! create config.h
|
||||
$!
|
||||
$ create []config.h
|
||||
/* config.h-vms. Generated by hand by Klaus K<>mpf, kkaempf@didymus.rmi.de. */
|
||||
/* config.in. Generated automatically from configure.in by autoheader. */
|
||||
/* Whether malloc must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_MALLOC */
|
||||
/* Whether free must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_FREE */
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
/* #define HAVE_MMAP 1 */
|
||||
/* Do we need to use the b modifier when opening binary files? */
|
||||
/* #undef USE_BINARY_FOPEN */
|
||||
/* Name of host specific header file to include in trad-core.c. */
|
||||
/* #undef TRAD_HEADER */
|
||||
/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t. */
|
||||
/* #undef HAVE_SYS_PROCFS_H */
|
||||
/* Do we really want to use mmap if it's available? */
|
||||
/* #undef USE_MMAP */
|
||||
/* Define if you have the fcntl function. */
|
||||
#define HAVE_FCNTL 1
|
||||
/* Define if you have the getpagesize function. */
|
||||
#define HAVE_GETPAGESIZE 1
|
||||
/* Define if you have the madvise function. */
|
||||
#define HAVE_MADVISE 1
|
||||
/* Define if you have the mprotect function. */
|
||||
#define HAVE_MPROTECT 1
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
/* Define if you have the <stddef.h> header file. */
|
||||
#define HAVE_STDDEF_H 1
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
/* Define if you have the <sys/file.h> header file. */
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
/* Define if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
$!
|
||||
$ write sys$output "Generated `config.h'"
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
# This file is a shell script that overrides some of the tools and
|
||||
# flags used on a host specific basis.
|
||||
|
||||
# Since the "bfd/hosts" directory is shared by the bfd, opcodes, and
|
||||
# binutils directories (at least), the index to it is also shared.
|
||||
# This is that index. Each configure.in file should source this file
|
||||
# in its per-host part.
|
||||
|
||||
# This sets the following shell variables:
|
||||
# HDEFINES host specific compiler options
|
||||
# host64 set to true if 64 bit types are as fast as 32 bit
|
||||
# HOST_64BIT_TYPE host 64 bit type
|
||||
# HOST_U_64BIT_TYPE unsigned 64 bit type (not needed if 64BIT_TYPE is long)
|
||||
|
||||
HDEFINES=
|
||||
host64=false
|
||||
HOST_64BIT_TYPE=
|
||||
HOST_U_64BIT_TYPE=
|
||||
|
||||
case "${host}" in
|
||||
|
||||
hppa*-*-hpux*) # HP/UX's ftello64 et.al. declarations are only
|
||||
# visible when _LARGEFILE64_SOURCE is defined.
|
||||
# Without those declarations, real_ftell et.al.
|
||||
# get mis-compiled.
|
||||
HDEFINES="-DHOST_HPPAHPUX -D_LARGEFILE64_SOURCE" ;;
|
||||
hppa*-*-hiux*) HDEFINES=-DHOST_HPPAHPUX ;;
|
||||
hppa*-*-mpeix*) HDEFINES=-DHOST_HPPAMPEIX ;;
|
||||
hppa*-*-bsd*) HDEFINES=-DHOST_HPPABSD ;;
|
||||
hppa*-*-osf*) HDEFINES=-DHOST_HPPAOSF ;;
|
||||
|
||||
ia64-*-*) host64=true;;
|
||||
|
||||
# Workaround for limitations on win9x where file contents are
|
||||
# not zero'd out if you seek past the end and then write.
|
||||
i[3-7]86-*-mingw32*) HDEFINES=-D__USE_MINGW_FSEEK;;
|
||||
|
||||
i[3-7]86-sequent-bsd*) HDEFINES=-Dshared=genshared ;;
|
||||
i[3-7]86-sequent-sysv4*) ;;
|
||||
i[3-7]86-sequent-sysv*) HDEFINES=-Dshared=genshared ;;
|
||||
|
||||
mips*-*-netbsd*) ;;
|
||||
mips*-*-openbsd*) ;;
|
||||
mips*-dec-*) HDEFINES="-G 4" ;;
|
||||
mips*-sgi-irix3*) HDEFINES="-G 4" ;;
|
||||
mips*-sgi-irix4*) HDEFINES="-G 4" ;;
|
||||
mips*-sgi-irix6*) host64=true;;
|
||||
mips64*-*-linux*) host64=true;;
|
||||
mips*-*-sysv4*) ;;
|
||||
mips*-*-sysv*) HDEFINES="-G 4" ;;
|
||||
mips*-*-riscos*) HDEFINES="-G 4" ;;
|
||||
|
||||
m68*-hp-hpux*) HDEFINES=-DHOST_HP300HPUX ;;
|
||||
|
||||
*-*-windows*)
|
||||
HOST_64BIT_TYPE=__int64
|
||||
HOST_U_64BIT_TYPE="unsigned __int64"
|
||||
# The following krock is necessary because we can't run the build compiler
|
||||
# (MSVC) on the configure host, so we have to explicitly set the values here.
|
||||
# Note that this file is never run through autoconf, so we can't use any
|
||||
# autoconf macros here. Because of this, we have to muck with autoconf
|
||||
# variables explicitly.
|
||||
ac_cv_func_mmap_fixed_mapped=no
|
||||
ac_cv_header_time=no
|
||||
ac_cv_func_getpagesize=no
|
||||
ac_cv_func_madvise=no
|
||||
ac_cv_func_mprotect=no
|
||||
ac_cv_func_getuid=no
|
||||
ac_cv_func_getgid=no
|
||||
ac_cv_header_sys_file_h=no
|
||||
ac_cv_header_sys_time_h=no
|
||||
ac_cv_header_unistd_h=no
|
||||
;;
|
||||
esac
|
||||
949
bfd/configure.in
949
bfd/configure.in
@@ -1,949 +0,0 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
dnl
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([libbfd.c])
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
AC_ISC_POSIX
|
||||
|
||||
AM_INIT_AUTOMAKE(bfd, 2.15.93)
|
||||
|
||||
dnl These must be called before AM_PROG_LIBTOOL, because it may want
|
||||
dnl to call AC_CHECK_PROG.
|
||||
AC_CHECK_TOOL(AR, ar)
|
||||
AC_CHECK_TOOL(RANLIB, ranlib, :)
|
||||
|
||||
dnl Default to a non shared library. This may be overridden by the
|
||||
dnl configure option --enable-shared.
|
||||
AM_DISABLE_SHARED
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
AC_ARG_ENABLE(64-bit-bfd,
|
||||
[ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
|
||||
[case "${enableval}" in
|
||||
yes) want64=true ;;
|
||||
no) want64=false ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
|
||||
esac],[want64=false])dnl
|
||||
AC_ARG_ENABLE(targets,
|
||||
[ --enable-targets alternative target configurations],
|
||||
[case "${enableval}" in
|
||||
yes | "") AC_MSG_ERROR([enable-targets option must specify target names or 'all'])
|
||||
;;
|
||||
no) enable_targets= ;;
|
||||
*) enable_targets=$enableval ;;
|
||||
esac])dnl
|
||||
AC_ARG_ENABLE(commonbfdlib,
|
||||
[ --enable-commonbfdlib build shared BFD/opcodes/libiberty library],
|
||||
[case "${enableval}" in
|
||||
yes) commonbfdlib=true ;;
|
||||
no) commonbfdlib=false ;;
|
||||
*) AC_MSG_ERROR([bad value ${enableval} for BFD commonbfdlib option]) ;;
|
||||
esac])dnl
|
||||
AC_ARG_WITH(mmap,
|
||||
[ --with-mmap try using mmap for BFD input files if available],
|
||||
[case "${withval}" in
|
||||
yes) want_mmap=true ;;
|
||||
no) want_mmap=false ;;
|
||||
*) AC_MSG_ERROR(bad value ${withval} for BFD with-mmap option) ;;
|
||||
esac],[want_mmap=false])dnl
|
||||
|
||||
build_warnings="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
|
||||
AC_ARG_ENABLE(build-warnings,
|
||||
[ --enable-build-warnings Enable build-time compiler warnings if gcc is used],
|
||||
[case "${enableval}" in
|
||||
yes) ;;
|
||||
no) build_warnings="-w";;
|
||||
,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
|
||||
build_warnings="${build_warnings} ${t}";;
|
||||
*,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
|
||||
build_warnings="${t} ${build_warnings}";;
|
||||
*) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
|
||||
echo "Setting warning flags = $build_warnings" 6>&1
|
||||
fi])dnl
|
||||
WARN_CFLAGS=""
|
||||
if test "x${build_warnings}" != x && test "x$GCC" = xyes ; then
|
||||
WARN_CFLAGS="${build_warnings}"
|
||||
fi
|
||||
AC_SUBST(WARN_CFLAGS)
|
||||
|
||||
AM_CONFIG_HEADER(config.h:config.in)
|
||||
|
||||
if test -z "$target" ; then
|
||||
AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
|
||||
fi
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
AM_INSTALL_LIBBFD
|
||||
AC_EXEEXT
|
||||
|
||||
host64=false
|
||||
target64=false
|
||||
bfd_default_target_size=32
|
||||
|
||||
# host stuff:
|
||||
|
||||
AC_PROG_CC
|
||||
|
||||
ALL_LINGUAS="fr tr ja es sv da zh_CN ro"
|
||||
CY_GNU_GETTEXT
|
||||
|
||||
# Permit host specific settings.
|
||||
. ${srcdir}/configure.host
|
||||
|
||||
AC_SUBST(HDEFINES)
|
||||
AC_PROG_INSTALL
|
||||
|
||||
BFD_HOST_64BIT_LONG=0
|
||||
BFD_HOST_LONG_LONG=0
|
||||
BFD_HOST_64_BIT_DEFINED=0
|
||||
BFD_HOST_64_BIT=
|
||||
BFD_HOST_U_64_BIT=
|
||||
|
||||
AC_MSG_CHECKING([for long long])
|
||||
AC_CACHE_VAL(bfd_cv_has_long_long,
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[unsigned long long ll = 18446744073709551615ULL;]])],[bfd_cv_has_long_long=yes],[bfd_cv_has_long_long=no])])
|
||||
AC_MSG_RESULT($bfd_cv_has_long_long)
|
||||
if test $bfd_cv_has_long_long = yes; then
|
||||
BFD_HOST_LONG_LONG=1
|
||||
AC_COMPILE_CHECK_SIZEOF(long long)
|
||||
fi
|
||||
|
||||
AC_COMPILE_CHECK_SIZEOF(long)
|
||||
if test "x${ac_cv_sizeof_long}" = "x8"; then
|
||||
host64=true
|
||||
BFD_HOST_64BIT_LONG=1
|
||||
test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long"
|
||||
test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long"
|
||||
elif test "x${ac_cv_sizeof_long_long}" = "x8"; then
|
||||
test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long"
|
||||
test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long"
|
||||
fi
|
||||
|
||||
if test -n "${HOST_64BIT_TYPE}" -a -n "${HOST_U_64BIT_TYPE}"; then
|
||||
BFD_HOST_64_BIT_DEFINED=1
|
||||
BFD_HOST_64_BIT="${HOST_64BIT_TYPE}"
|
||||
BFD_HOST_U_64_BIT="${HOST_U_64BIT_TYPE}"
|
||||
fi
|
||||
|
||||
AC_SUBST(BFD_HOST_64BIT_LONG)
|
||||
AC_SUBST(BFD_HOST_LONG_LONG)
|
||||
AC_SUBST(BFD_HOST_64_BIT_DEFINED)
|
||||
AC_SUBST(BFD_HOST_64_BIT)
|
||||
AC_SUBST(BFD_HOST_U_64_BIT)
|
||||
|
||||
BFD_CC_FOR_BUILD
|
||||
|
||||
AC_CHECK_HEADERS(stddef.h string.h strings.h stdlib.h time.h unistd.h)
|
||||
AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h)
|
||||
AC_HEADER_TIME
|
||||
AC_HEADER_DIRENT
|
||||
AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid)
|
||||
AC_CHECK_FUNCS(strtoull)
|
||||
|
||||
BFD_BINARY_FOPEN
|
||||
|
||||
BFD_NEED_DECLARATION(strstr)
|
||||
BFD_NEED_DECLARATION(malloc)
|
||||
BFD_NEED_DECLARATION(realloc)
|
||||
BFD_NEED_DECLARATION(free)
|
||||
BFD_NEED_DECLARATION(getenv)
|
||||
|
||||
# If we are configured native, pick a core file support file.
|
||||
COREFILE=
|
||||
COREFLAG=
|
||||
TRAD_HEADER=
|
||||
if test "${target}" = "${host}"; then
|
||||
case "${host}" in
|
||||
alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
|
||||
COREFILE=''
|
||||
;;
|
||||
alpha*-*-linux-gnu*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/alphalinux.h"'
|
||||
;;
|
||||
alpha*-*-netbsd* | alpha*-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
alpha*-*-*) COREFILE=osf-core.lo ;;
|
||||
arm-*-freebsd* | arm-*-kfreebsd*-gnu)
|
||||
COREFILE='' ;;
|
||||
arm-*-netbsd*) COREFILE=netbsd-core.lo ;;
|
||||
arm-*-riscix) COREFILE=trad-core.lo ;;
|
||||
hppa*-*-hpux*) COREFILE=hpux-core.lo ;;
|
||||
hppa*-*-hiux*) COREFILE=hpux-core.lo ;;
|
||||
hppa*-*-mpeix*) COREFILE=hpux-core.lo ;;
|
||||
hppa*-*-bsd*) COREFILE="hpux-core.lo hppabsd-core.lo"
|
||||
COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
|
||||
hppa*-*-netbsd* | hppa*-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
|
||||
i370-*-*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/i370linux.h"'
|
||||
;;
|
||||
|
||||
changequote(,)dnl
|
||||
i[3-7]86-sequent-bsd*)
|
||||
changequote([,])dnl
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/symmetry.h"'
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-sequent-sysv4*) ;;
|
||||
i[3-7]86-sequent-sysv*)
|
||||
changequote([,])dnl
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/symmetry.h"'
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-bsdi)
|
||||
changequote([,])dnl
|
||||
COREFILE=
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-bsd* | i[3-7]86-*-freebsd[123] | i[3-7]86-*-freebsd[123]\.* | i[3-7]86-*-freebsd4\.[01234] | i[3-7]86-*-freebsd4\.[01234]\.* | i[3-7]86-*-freebsd*aout*)
|
||||
changequote([,])dnl
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/i386bsd.h"'
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-freebsd* | i[3-7]86-*-kfreebsd*-gnu)
|
||||
changequote([,])dnl
|
||||
COREFILE=''
|
||||
TRAD_HEADER='"hosts/i386bsd.h"'
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-netbsd* | i[3-7]86-*-knetbsd*-gnu | i[3-7]86-*-openbsd*)
|
||||
changequote([,])dnl
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-esix-sysv3*)
|
||||
changequote([,])dnl
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/esix.h"'
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-sco3.2v5*)
|
||||
changequote([,])dnl
|
||||
COREFILE=sco5-core.lo
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-sco* | i[3-7]86-*-isc*)
|
||||
changequote([,])dnl
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/i386sco.h"'
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-mach3*)
|
||||
changequote([,])dnl
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/i386mach3.h"'
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-linux-gnu*)
|
||||
changequote([,])dnl
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/i386linux.h"'
|
||||
;;
|
||||
changequote(,)dnl
|
||||
i[3-7]86-*-isc*) COREFILE=trad-core.lo ;;
|
||||
i[3-7]86-*-aix*) COREFILE=aix386-core.lo ;;
|
||||
changequote([,])dnl
|
||||
i860-*-mach3* | i860-*-osf1*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/i860mach3.h"'
|
||||
;;
|
||||
mips-*-netbsd* | mips*-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
mips-dec-*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/decstation.h"'
|
||||
;;
|
||||
mips-sgi-irix4*) COREFILE=irix-core.lo ;;
|
||||
mips-sgi-irix5*) COREFILE=irix-core.lo ;;
|
||||
mips-sgi-irix6*) COREFILE=irix-core.lo ;;
|
||||
mips-*-sysv4*) ;;
|
||||
mips-*-sysv* | mips-*-riscos*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/riscos.h"'
|
||||
;;
|
||||
mips-sony-bsd*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/news-mips.h"'
|
||||
;;
|
||||
m68*-bull*-sysv*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/dpx2.h"'
|
||||
;;
|
||||
m68*-hp-hpux*) COREFILE=hpux-core.lo ;;
|
||||
m68*-hp-bsd*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/hp300bsd.h"'
|
||||
;;
|
||||
m68*-*-linux-gnu*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/m68klinux.h"'
|
||||
;;
|
||||
m68*-motorola-sysv*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/delta68.h"'
|
||||
;;
|
||||
m68*-sony-*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/news.h"'
|
||||
;;
|
||||
m68*-*-netbsd* | m68*-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
m68*-apple-aux*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/m68kaux.h"'
|
||||
;;
|
||||
m88*-*-sysv4*)
|
||||
;;
|
||||
m88*-motorola-sysv*)
|
||||
COREFILE=ptrace-core.lo
|
||||
;;
|
||||
m88*-*-mach3*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/m88kmach3.h"'
|
||||
;;
|
||||
m88*-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
ns32k-pc532-mach)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/pc532mach.h"'
|
||||
;;
|
||||
ns32k-*-netbsd* | ns32k-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
rs6000-*-lynx*)
|
||||
COREFILE=lynx-core.lo
|
||||
;;
|
||||
rs6000-*-aix5.* | powerpc-*-aix5.*)
|
||||
COREFILE=rs6000-core.lo
|
||||
COREFLAG="$COREFLAG -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE"
|
||||
;;
|
||||
changequote(,)dnl
|
||||
rs6000-*-aix4.[3-9]* | powerpc-*-aix4.[3-9]*)
|
||||
changequote([,])dnl
|
||||
COREFILE=rs6000-core.lo
|
||||
COREFLAG="$COREFLAG -DAIX_CORE_DUMPX_CORE"
|
||||
# Not all versions of AIX with -DAIX_CORE_DUMPX_CORE
|
||||
# have c_impl as a member of struct core_dumpx
|
||||
AC_MSG_CHECKING([for c_impl in struct core_dumpx])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <core.h>]], [[struct core_dumpx c; c.c_impl = 0;]])],[AC_DEFINE(HAVE_ST_C_IMPL, 1,
|
||||
[Define if struct core_dumpx has member c_impl])
|
||||
AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
|
||||
;;
|
||||
rs6000-*-aix4*) COREFILE=rs6000-core.lo ;;
|
||||
rs6000-*-*) COREFILE=rs6000-core.lo ;;
|
||||
powerpc-*-aix4*) COREFILE=rs6000-core.lo ;;
|
||||
powerpc-*-aix*) COREFILE=rs6000-core.lo ;;
|
||||
powerpc-*-beos*) ;;
|
||||
powerpc-*-freebsd* | powerpc-*-kfreebsd*-gnu)
|
||||
COREFILE='' ;;
|
||||
powerpc-*-netbsd*) COREFILE=netbsd-core.lo ;;
|
||||
powerpc-*-*bsd*) COREFILE=netbsd-core.lo ;;
|
||||
s390*-*-*) COREFILE=trad-core.lo ;;
|
||||
sh*-*-netbsd*) COREFILE=netbsd-core.lo ;;
|
||||
sparc-*-netbsd* | sparc*-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
tahoe-*-*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/tahoe.h"'
|
||||
;;
|
||||
vax-*-netbsd* | vax-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
vax-*-ultrix2*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/vaxult2.h"'
|
||||
;;
|
||||
vax-*-ultrix*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/vaxult2.h"'
|
||||
;;
|
||||
vax-*-linux-gnu*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/vaxlinux.h"'
|
||||
;;
|
||||
vax-*-*)
|
||||
COREFILE=trad-core.lo
|
||||
TRAD_HEADER='"hosts/vaxbsd.h"'
|
||||
;;
|
||||
x86_64-*-netbsd* | x86_64-*-openbsd*)
|
||||
COREFILE=netbsd-core.lo
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$COREFILE" in
|
||||
aix386-core.lo) COREFLAG=-DAIX386_CORE ;;
|
||||
hppabsd-core.lo) COREFLAG=-DHPPABSD_CORE ;;
|
||||
hpux-core.lo) COREFLAG=-DHPUX_CORE ;;
|
||||
irix-core.lo) COREFLAG=-DIRIX_CORE ;;
|
||||
lynx-core.lo) COREFLAG=-DLYNX_CORE ;;
|
||||
netbsd-core.lo) COREFLAG=-DNETBSD_CORE ;;
|
||||
osf-core.lo) COREFLAG=-DOSF_CORE ;;
|
||||
ptrace-core.lo) COREFLAG=-DPTRACE_CORE ;;
|
||||
rs6000-core.lo) COREFLAG="$COREFLAG -DAIX_CORE" ;;
|
||||
sco5-core.lo) COREFLAG="$COREFLAG -DSCO5_CORE" ;;
|
||||
trad-core.lo) COREFLAG="$COREFLAG -DTRAD_CORE" ;;
|
||||
esac
|
||||
|
||||
# ELF corefile support has several flavors, but all of
|
||||
# them use something called <sys/procfs.h>
|
||||
AC_CHECK_HEADERS(sys/procfs.h)
|
||||
if test "$ac_cv_header_sys_procfs_h" = yes; then
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(prstatus_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(prstatus32_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prstatus_t, pr_who)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prstatus32_t, pr_who)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(pstatus_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(pxstatus_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(pstatus32_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo32_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(psinfo_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(psinfo32_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(lwpstatus_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(lwpxstatus_t)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_context)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_reg)
|
||||
BFD_HAVE_SYS_PROCFS_TYPE(win32_pstatus_t)
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(COREFILE)
|
||||
AC_SUBST(COREFLAG)
|
||||
if test -n "$TRAD_HEADER"; then
|
||||
AC_DEFINE_UNQUOTED(TRAD_HEADER, $TRAD_HEADER,
|
||||
[Name of host specific header file to include in trad-core.c.])
|
||||
fi
|
||||
|
||||
# Horrible hacks to build DLLs on Windows.
|
||||
WIN32LDFLAGS=
|
||||
WIN32LIBADD=
|
||||
case "${host}" in
|
||||
*-*-cygwin*)
|
||||
if test "$enable_shared" = "yes"; then
|
||||
WIN32LDFLAGS="-no-undefined"
|
||||
WIN32LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
|
||||
fi
|
||||
;;
|
||||
*-*-linux*)
|
||||
# We borrow WIN32LIBADD so that the shared libbfd won't depend on
|
||||
# libiberty.a.
|
||||
case "${host}" in
|
||||
mips*-*-linux*)
|
||||
# Linux/MIPS uses PIC by default.
|
||||
if test "$enable_shared" = "yes"; then
|
||||
WIN32LIBADD="-L../libiberty -liberty"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
changequote(,)dnl
|
||||
x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'`
|
||||
changequote([,])dnl
|
||||
if test -n "$x"; then
|
||||
WIN32LIBADD="-L../libiberty/pic -liberty"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(WIN32LDFLAGS)
|
||||
AC_SUBST(WIN32LIBADD)
|
||||
|
||||
# target stuff:
|
||||
|
||||
# Canonicalize the secondary target names.
|
||||
if test -n "$enable_targets" ; then
|
||||
for targ in `echo $enable_targets | sed 's/,/ /g'`
|
||||
do
|
||||
result=`$ac_config_sub $targ 2>/dev/null`
|
||||
if test -n "$result" ; then
|
||||
canon_targets="$canon_targets $result"
|
||||
else
|
||||
# Allow targets that config.sub doesn't recognize, like "all".
|
||||
canon_targets="$canon_targets $targ"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
all_targets=false
|
||||
defvec=
|
||||
selvecs=
|
||||
assocvecs=
|
||||
selarchs=
|
||||
TDEFINES=
|
||||
for targ in $target $canon_targets
|
||||
do
|
||||
if test "x$targ" = "xall"; then
|
||||
all_targets=true
|
||||
assocvecs="$assocvecs $targ_defvec $targ_selvecs"
|
||||
else
|
||||
. $srcdir/config.bfd
|
||||
if test "x$targ" = "x$target"; then
|
||||
defvec=$targ_defvec
|
||||
fi
|
||||
selvecs="$selvecs $targ_defvec $targ_selvecs"
|
||||
selarchs="$selarchs $targ_archs"
|
||||
TDEFINES="$TDEFINES $targ_cflags"
|
||||
fi
|
||||
done
|
||||
AC_SUBST(TDEFINES)
|
||||
|
||||
# This processing still needs to be done if we're to decide properly whether
|
||||
# 64-bit support needs to be compiled in. Currently, it will be included if
|
||||
# the default or any other explicitly requested target requires it; it
|
||||
# will not be included on a 32-bit host if no 64-bit target is requested, and
|
||||
# no "--with-64-bit-bfd" option is given, even if "--enable-targets=all" is
|
||||
# used.
|
||||
|
||||
# uniq the default and selected vectors in all the configured targets.
|
||||
f=""
|
||||
for i in $selvecs ; do
|
||||
case " $f " in
|
||||
*" $i "*) ;;
|
||||
*) f="$f $i" ;;
|
||||
esac
|
||||
done
|
||||
selvecs="$f"
|
||||
|
||||
|
||||
# uniq the associated vectors in all the configured targets.
|
||||
f=""
|
||||
for i in $assocvecs ; do
|
||||
case " $f " in
|
||||
*" $i "*) ;;
|
||||
*) f="$f $i" ;;
|
||||
esac
|
||||
done
|
||||
assocvecs="$f"
|
||||
|
||||
|
||||
# uniq the architectures in all the configured targets.
|
||||
f=""
|
||||
for i in $selarchs ; do
|
||||
case " $f " in
|
||||
*" $i "*) ;;
|
||||
*) f="$f $i" ;;
|
||||
esac
|
||||
done
|
||||
selarchs="$f"
|
||||
|
||||
# Target backend .o files.
|
||||
tb=
|
||||
|
||||
elf="elf.lo elflink.lo elf-strtab.lo elf-eh-frame.lo dwarf1.lo"
|
||||
|
||||
for vec in $selvecs
|
||||
do
|
||||
target_size=32
|
||||
case "$vec" in
|
||||
# This list is alphabetized to make it easy to compare
|
||||
# with the two vector lists in targets.c. For the same reason,
|
||||
# use one entry per line, even though this leads to long lines.
|
||||
a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;;
|
||||
a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;;
|
||||
aix5coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
|
||||
aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;;
|
||||
aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;;
|
||||
aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;;
|
||||
apollocoff_vec) tb="$tb coff-apollo.lo" ;;
|
||||
arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
|
||||
arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
|
||||
arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
|
||||
arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
|
||||
armcoff_big_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
|
||||
armcoff_little_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
|
||||
armnetbsd_vec) tb="$tb armnetbsd.lo aout32.lo" ;;
|
||||
armpe_big_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
|
||||
armpe_little_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
|
||||
armpei_big_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
|
||||
armpei_little_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
|
||||
b_out_vec_big_host) tb="$tb bout.lo aout32.lo" ;;
|
||||
b_out_vec_little_host) tb="$tb bout.lo aout32.lo" ;;
|
||||
bfd_efi_app_ia32_vec) tb="$tb efi-app-ia32.lo peigen.lo cofflink.lo" ;;
|
||||
bfd_efi_app_ia64_vec) tb="$tb efi-app-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
|
||||
bfd_elf32_am33lin_vec) tb="$tb elf32-am33lin.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_avr_vec) tb="$tb elf32-avr.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_bigarm_symbian_vec)
|
||||
tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
|
||||
bfd_elf32_cr16c_vec) tb="$tb elf32-cr16c.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_crx_vec) tb="$tb elf32-crx.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_d30v_vec) tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_dlx_big_vec) tb="$tb elf32-dlx.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_fr30_vec) tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_frv_vec) tb="$tb elf32-frv.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_frvfdpic_vec) tb="$tb elf32-frv.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_h8300_vec) tb="$tb elf32-h8300.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_hppa_linux_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_hppa_nbsd_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_hppa_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_i370_vec) tb="$tb elf32-i370.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_i386_freebsd_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_i860_little_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_i960_vec) tb="$tb elf32-i960.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_ia64_big_vec) tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_ia64_hpux_big_vec) tb="$tb elf32-ia64.lo elf32.lo $elf";;
|
||||
bfd_elf32_ip2k_vec) tb="$tb elf32-ip2k.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_iq2000_vec) tb="$tb elf32-iq2000.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_littlearm_symbian_vec)
|
||||
tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
|
||||
bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_m32rle_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_m32rlin_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_m32rlelin_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_m68hc11_vec) tb="$tb elf32-m68hc11.lo elf32-m68hc1x.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_m68hc12_vec) tb="$tb elf32-m68hc12.lo elf32-m68hc1x.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_m68k_vec) tb="$tb elf32-m68k.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_m88k_vec) tb="$tb elf32-m88k.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_mcore_big_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_mcore_little_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_mn10200_vec) tb="$tb elf-m10200.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_msp430_vec) tb="$tb elf32-msp430.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_nbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
|
||||
bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
|
||||
bfd_elf32_ntradbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
|
||||
bfd_elf32_ntradlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
|
||||
bfd_elf32_openrisc_vec) tb="$tb elf32-openrisc.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_or32_big_vec) tb="$tb elf32-or32.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";;
|
||||
bfd_elf32_pjl_vec) tb="$tb elf32-pj.lo elf32.lo $elf";;
|
||||
bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
|
||||
# FIXME: We include cofflink.lo not because it's needed for
|
||||
# bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
|
||||
# which needs it but does not list it. Should be fixed in right place.
|
||||
bfd_elf32_sh64_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
|
||||
bfd_elf32_sh64l_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
|
||||
bfd_elf32_sh64lin_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
|
||||
bfd_elf32_sh64blin_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
|
||||
bfd_elf32_sh64lnbsd_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;;
|
||||
bfd_elf32_sh64nbsd_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;;
|
||||
bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
|
||||
bfd_elf32_shblin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
|
||||
bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
|
||||
bfd_elf32_shl_symbian_vec) tb="$tb elf32-sh-symbian.lo elf32-sh64-com.lo elf32.lo $elf coff-sh.lo" ;;
|
||||
bfd_elf32_shlin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
|
||||
bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
|
||||
bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
|
||||
bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
|
||||
bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
|
||||
bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_vax_vec) tb="$tb elf32-vax.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_xstormy16_vec) tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_xtensa_le_vec) tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
|
||||
bfd_elf32_xtensa_be_vec) tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
|
||||
bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
|
||||
bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
|
||||
bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
|
||||
bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
|
||||
bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_sh64_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
|
||||
bfd_elf64_sh64l_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
|
||||
bfd_elf64_sh64lin_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
|
||||
bfd_elf64_sh64blin_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
|
||||
bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
|
||||
bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
|
||||
bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
|
||||
bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
|
||||
bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;;
|
||||
bfd_mmo_vec) tb="$tb mmo.lo" target_size=64 ;;
|
||||
bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
|
||||
bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
|
||||
bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
|
||||
bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
|
||||
cris_aout_vec) tb="$tb aout-cris.lo" ;;
|
||||
demo_64_vec) tb="$tb demo64.lo aout64.lo"; target_size=64 ;;
|
||||
ecoff_big_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
|
||||
ecoff_biglittle_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
|
||||
ecoff_little_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
|
||||
ecoffalpha_little_vec) tb="$tb coff-alpha.lo ecoff.lo ecofflink.lo"; target_size=64 ;;
|
||||
go32coff_vec) tb="$tb coff-go32.lo cofflink.lo" ;;
|
||||
go32stubbedcoff_vec) tb="$tb coff-stgo32.lo cofflink.lo" ;;
|
||||
h8300coff_vec) tb="$tb coff-h8300.lo reloc16.lo" ;;
|
||||
h8500coff_vec) tb="$tb coff-h8500.lo reloc16.lo" ;;
|
||||
host_aout_vec) tb="$tb host-aout.lo aout32.lo" ;;
|
||||
hp300bsd_vec) tb="$tb hp300bsd.lo aout32.lo" ;;
|
||||
hp300hpux_vec) tb="$tb hp300hpux.lo aout32.lo" ;;
|
||||
i386aout_vec) tb="$tb i386aout.lo aout32.lo" ;;
|
||||
i386bsd_vec) tb="$tb i386bsd.lo aout32.lo" ;;
|
||||
i386coff_vec) tb="$tb coff-i386.lo cofflink.lo" ;;
|
||||
i386dynix_vec) tb="$tb i386dynix.lo aout32.lo" ;;
|
||||
i386freebsd_vec) tb="$tb i386freebsd.lo aout32.lo" ;;
|
||||
i386linux_vec) tb="$tb i386linux.lo aout32.lo" ;;
|
||||
i386lynx_aout_vec) tb="$tb i386lynx.lo lynx-core.lo aout32.lo" ;;
|
||||
i386lynx_coff_vec) tb="$tb cf-i386lynx.lo cofflink.lo lynx-core.lo" ;;
|
||||
i386mach3_vec) tb="$tb i386mach3.lo aout32.lo" ;;
|
||||
i386msdos_vec) tb="$tb i386msdos.lo" ;;
|
||||
i386netbsd_vec) tb="$tb i386netbsd.lo aout32.lo" ;;
|
||||
i386os9k_vec) tb="$tb i386os9k.lo aout32.lo" ;;
|
||||
i386pe_vec) tb="$tb pe-i386.lo peigen.lo cofflink.lo" ;;
|
||||
i386pei_vec) tb="$tb pei-i386.lo peigen.lo cofflink.lo" ;;
|
||||
i860coff_vec) tb="$tb coff-i860.lo cofflink.lo" ;;
|
||||
icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
|
||||
icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
|
||||
ieee_vec) tb="$tb ieee.lo" ;;
|
||||
m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
|
||||
m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
|
||||
m68kcoff_vec) tb="$tb coff-m68k.lo cofflink.lo" ;;
|
||||
m68kcoffun_vec) tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
|
||||
m68klinux_vec) tb="$tb m68klinux.lo aout32.lo" ;;
|
||||
m68klynx_aout_vec) tb="$tb m68klynx.lo lynx-core.lo aout32.lo" ;;
|
||||
m68klynx_coff_vec) tb="$tb cf-m68klynx.lo coff-m68k.lo cofflink.lo lynx-core.lo" ;;
|
||||
m68knetbsd_vec) tb="$tb m68knetbsd.lo aout32.lo" ;;
|
||||
m68ksysvcoff_vec) tb="$tb coff-svm68k.lo cofflink.lo" ;;
|
||||
m88kbcs_vec) tb="$tb coff-m88k.lo" ;;
|
||||
m88kmach3_vec) tb="$tb m88kmach3.lo aout32.lo" ;;
|
||||
m88kopenbsd_vec) tb="$tb m88kopenbsd.lo aout32.lo" ;;
|
||||
mach_o_be_vec) tb="$tb mach-o.lo" ;;
|
||||
mach_o_le_vec) tb="$tb mach-o.lo" ;;
|
||||
mach_o_fat_vec) tb="$tb mach-o.lo" ;;
|
||||
mcore_pe_big_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;;
|
||||
mcore_pe_little_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;;
|
||||
mcore_pei_big_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;;
|
||||
mcore_pei_little_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;;
|
||||
mipslpe_vec) tb="$tb pe-mips.lo peigen.lo cofflink.lo" ;;
|
||||
mipslpei_vec) tb="$tb pei-mips.lo peigen.lo cofflink.lo" ;;
|
||||
newsos3_vec) tb="$tb newsos3.lo aout32.lo" ;;
|
||||
nlm32_alpha_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"; target_size=64 ;;
|
||||
nlm32_i386_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;;
|
||||
nlm32_powerpc_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;;
|
||||
nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
|
||||
or32coff_big_vec) tb="$tb coff-or32.lo cofflink.lo" ;;
|
||||
pc532machaout_vec) tb="$tb pc532-mach.lo aout-ns32k.lo" ;;
|
||||
pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;;
|
||||
pef_vec) tb="$tb pef.lo" ;;
|
||||
pef_xlib_vec) tb="$tb pef.lo" ;;
|
||||
pdp11_aout_vec) tb="$tb pdp11.lo" ;;
|
||||
pmac_xcoff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
|
||||
ppcboot_vec) tb="$tb ppcboot.lo" ;;
|
||||
riscix_vec) tb="$tb aout32.lo riscix.lo" ;;
|
||||
rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
|
||||
rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
|
||||
shcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
|
||||
shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
|
||||
shlcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
|
||||
shlcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
|
||||
shlpe_vec) tb="$tb pe-sh.lo coff-sh.lo peigen.lo cofflink.lo" ;;
|
||||
shlpei_vec) tb="$tb pei-sh.lo coff-sh.lo peigen.lo cofflink.lo" ;;
|
||||
som_vec) tb="$tb som.lo" ;;
|
||||
sparccoff_vec) tb="$tb coff-sparc.lo" ;;
|
||||
sparcle_aout_vec) tb="$tb aout-sparcle.lo aout32.lo" ;;
|
||||
sparclinux_vec) tb="$tb sparclinux.lo aout32.lo" ;;
|
||||
sparclynx_aout_vec) tb="$tb sparclynx.lo lynx-core.lo aout32.lo" ;;
|
||||
sparclynx_coff_vec) tb="$tb cf-sparclynx.lo lynx-core.lo" ;;
|
||||
sparcnetbsd_vec) tb="$tb sparcnetbsd.lo aout32.lo" ;;
|
||||
sunos_big_vec) tb="$tb sunos.lo aout32.lo" ;;
|
||||
sym_vec) tb="$tb xsym.lo" ;;
|
||||
tic30_aout_vec) tb="$tb aout-tic30.lo" ;;
|
||||
tic30_coff_vec) tb="$tb coff-tic30.lo" ;;
|
||||
tic4x_coff0_vec) tb="$tb coff-tic4x.lo" ;;
|
||||
tic4x_coff0_beh_vec) tb="$tb coff-tic4x.lo" ;;
|
||||
tic4x_coff1_vec) tb="$tb coff-tic4x.lo" ;;
|
||||
tic4x_coff1_beh_vec) tb="$tb coff-tic4x.lo" ;;
|
||||
tic4x_coff2_vec) tb="$tb coff-tic4x.lo" ;;
|
||||
tic4x_coff2_beh_vec) tb="$tb coff-tic4x.lo" ;;
|
||||
tic54x_coff0_beh_vec) tb="$tb coff-tic54x.lo" ;;
|
||||
tic54x_coff0_vec) tb="$tb coff-tic54x.lo" ;;
|
||||
tic54x_coff1_beh_vec) tb="$tb coff-tic54x.lo" ;;
|
||||
tic54x_coff1_vec) tb="$tb coff-tic54x.lo" ;;
|
||||
tic54x_coff2_beh_vec) tb="$tb coff-tic54x.lo" ;;
|
||||
tic54x_coff2_vec) tb="$tb coff-tic54x.lo" ;;
|
||||
tic80coff_vec) tb="$tb coff-tic80.lo cofflink.lo" ;;
|
||||
vaxnetbsd_vec) tb="$tb vaxnetbsd.lo aout32.lo" ;;
|
||||
vax1knetbsd_vec) tb="$tb vax1knetbsd.lo aout32.lo" ;;
|
||||
vaxbsd_vec) tb="$tb vaxbsd.lo aout32.lo" ;;
|
||||
versados_vec) tb="$tb versados.lo" ;;
|
||||
vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"; target_size=64 ;;
|
||||
vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;;
|
||||
w65_vec) tb="$tb coff-w65.lo reloc16.lo" ;;
|
||||
we32kcoff_vec) tb="$tb coff-we32k.lo" ;;
|
||||
z8kcoff_vec) tb="$tb coff-z8k.lo reloc16.lo" ;;
|
||||
|
||||
# These appear out of order in targets.c
|
||||
srec_vec) tb="$tb srec.lo" ;;
|
||||
symbolsrec_vec) tb="$tb srec.lo" ;;
|
||||
tekhex_vec) tb="$tb tekhex.lo" ;;
|
||||
cisco_core_big_vec) tb="$tb cisco-core.lo" ;;
|
||||
cisco_core_little_vec) tb="$tb cisco-core.lo" ;;
|
||||
|
||||
"") ;;
|
||||
*) AC_MSG_ERROR(*** unknown target vector $vec) ;;
|
||||
esac
|
||||
|
||||
if test ${target_size} = 64; then
|
||||
target64=true
|
||||
fi
|
||||
if test x"${vec}" = x"${defvec}"; then
|
||||
bfd_default_target_size=${target_size}
|
||||
fi
|
||||
done
|
||||
|
||||
# Target architecture .o files.
|
||||
# A couple of CPUs use shorter file names to avoid problems on DOS
|
||||
# filesystems.
|
||||
ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.lo/g -e s/mn10200/m10200/ -e s/mn10300/m10300/`
|
||||
|
||||
# Weed out duplicate .o files.
|
||||
f=""
|
||||
for i in $tb ; do
|
||||
case " $f " in
|
||||
*" $i "*) ;;
|
||||
*) f="$f $i" ;;
|
||||
esac
|
||||
done
|
||||
tb="$f"
|
||||
|
||||
f=""
|
||||
for i in $ta ; do
|
||||
case " $f " in
|
||||
*" $i "*) ;;
|
||||
*) f="$f $i" ;;
|
||||
esac
|
||||
done
|
||||
ta="$f"
|
||||
|
||||
bfd_backends="$tb"
|
||||
bfd_machines="$ta"
|
||||
|
||||
if test x${all_targets} = xtrue ; then
|
||||
bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)'
|
||||
bfd_machines="${bfd_machines}"' $(ALL_MACHINES)'
|
||||
selvecs=
|
||||
havevecs=
|
||||
selarchs=
|
||||
test -n "$assocvecs" &&
|
||||
assocvecs=`echo $assocvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
|
||||
else # all_targets is true
|
||||
# Only set these if they will be nonempty, for the clever echo.
|
||||
havevecs=
|
||||
assocvecs=
|
||||
test -n "$selvecs" &&
|
||||
havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'`
|
||||
test -n "$selvecs" &&
|
||||
selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
|
||||
test -n "$selarchs" &&
|
||||
selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
|
||||
fi # all_targets is true
|
||||
|
||||
case ${host64}-${target64}-${want64} in
|
||||
*true*)
|
||||
wordsize=64
|
||||
bfd_libs='$(BFD64_LIBS) $(BFD32_LIBS)'
|
||||
all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)'
|
||||
if test $BFD_HOST_64_BIT_DEFINED = 0; then
|
||||
AC_MSG_WARN([You have requested a 64 bit BFD configuration, but])
|
||||
AC_MSG_WARN([your compiler may not have a 64 bit integral type])
|
||||
fi
|
||||
if test -n "$GCC" ; then
|
||||
bad_64bit_gcc=no;
|
||||
AC_MSG_CHECKING([for gcc version with buggy 64-bit support])
|
||||
# Add more tests for gcc versions with non-working 64-bit support here.
|
||||
AC_EGREP_CPP([: 2 : 91 : 1 :],[:__GNUC__:__GNUC_MINOR__:__i386__:],
|
||||
bad_64bit_gcc=yes;
|
||||
AC_MSG_RESULT([yes: egcs-1.1.2 on ix86 spotted]),
|
||||
AC_MSG_RESULT(no))
|
||||
if test $bad_64bit_gcc = yes ; then
|
||||
AC_MSG_ERROR([A newer version of gcc is needed for the requested 64-bit BFD configuration])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
false-false-false)
|
||||
wordsize=32
|
||||
bfd_libs='$(BFD32_LIBS)'
|
||||
all_backends='$(BFD32_BACKENDS)'
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(wordsize)
|
||||
AC_SUBST(bfd_libs)
|
||||
AC_SUBST(all_backends)
|
||||
AC_SUBST(bfd_backends)
|
||||
AC_SUBST(bfd_machines)
|
||||
AC_SUBST(bfd_default_target_size)
|
||||
|
||||
# Determine the host dependant file_ptr a.k.a. off_t type. In order
|
||||
# prefer: off64_t - if ftello64 and fseeko64, off_t - if ftello and
|
||||
# fseeko, long. This assumes that sizeof off_t is .ge. sizeof long.
|
||||
# Hopefully a reasonable assumption since fseeko et.al. should be
|
||||
# upward compatible.
|
||||
AC_CHECK_FUNCS(ftello ftello64 fseeko fseeko64)
|
||||
if test x"$ac_cv_func_ftello" = xyes -a x"$ac_cv_func_fseeko" = xyes; then
|
||||
AC_COMPILE_CHECK_SIZEOF(off_t)
|
||||
fi
|
||||
AC_MSG_CHECKING([file_ptr type])
|
||||
bfd_file_ptr="long"
|
||||
bfd_ufile_ptr="unsigned long"
|
||||
if test x"$ac_cv_func_ftello64" = xyes -a x"$ac_cv_func_fseeko64" = xyes \
|
||||
-o x"${ac_cv_sizeof_off_t}" = x8; then
|
||||
bfd_file_ptr=BFD_HOST_64_BIT
|
||||
bfd_ufile_ptr=BFD_HOST_U_64_BIT
|
||||
fi
|
||||
AC_MSG_RESULT($bfd_file_ptr)
|
||||
AC_SUBST(bfd_file_ptr)
|
||||
AC_SUBST(bfd_ufile_ptr)
|
||||
|
||||
|
||||
tdefaults=""
|
||||
test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
|
||||
test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
|
||||
test -n "${assocvecs}" && tdefaults="${tdefaults} -DASSOCIATED_VECS='${assocvecs}'"
|
||||
test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
|
||||
test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}"
|
||||
AC_SUBST(tdefaults)
|
||||
|
||||
dnl AC_CHECK_HEADERS(sys/mman.h)
|
||||
AC_FUNC_MMAP
|
||||
AC_CHECK_FUNCS(madvise mprotect)
|
||||
case ${want_mmap}+${ac_cv_func_mmap_fixed_mapped} in
|
||||
true+yes ) AC_DEFINE(USE_MMAP, 1, [Use mmap if it's available?]) ;;
|
||||
esac
|
||||
|
||||
rm -f doc/config.status
|
||||
AC_CONFIG_FILES([Makefile doc/Makefile bfd-in3.h:bfd-in2.h po/Makefile.in:po/Make-in])
|
||||
AC_CONFIG_COMMANDS([default],[[sed -e '/SRC-POTFILES =/r po/SRC-POTFILES' -e '/BLD-POTFILES =/r po/BLD-POTFILES' po/Makefile.in > po/Makefile]],[[]])
|
||||
AC_OUTPUT
|
||||
|
||||
106
bfd/corefile.c
106
bfd/corefile.c
@@ -1,106 +0,0 @@
|
||||
/* Core file generic interface routines for BFD.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 2000, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/*
|
||||
SECTION
|
||||
Core files
|
||||
|
||||
DESCRIPTION
|
||||
These are functions pertaining to core files.
|
||||
*/
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_core_file_failing_command
|
||||
|
||||
SYNOPSIS
|
||||
const char *bfd_core_file_failing_command (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return a read-only string explaining which program was running
|
||||
when it failed and produced the core file @var{abfd}.
|
||||
|
||||
*/
|
||||
|
||||
const char *
|
||||
bfd_core_file_failing_command (bfd *abfd)
|
||||
{
|
||||
if (abfd->format != bfd_core)
|
||||
{
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return NULL;
|
||||
}
|
||||
return BFD_SEND (abfd, _core_file_failing_command, (abfd));
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_core_file_failing_signal
|
||||
|
||||
SYNOPSIS
|
||||
int bfd_core_file_failing_signal (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Returns the signal number which caused the core dump which
|
||||
generated the file the BFD @var{abfd} is attached to.
|
||||
*/
|
||||
|
||||
int
|
||||
bfd_core_file_failing_signal (bfd *abfd)
|
||||
{
|
||||
if (abfd->format != bfd_core)
|
||||
{
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return 0;
|
||||
}
|
||||
return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
core_file_matches_executable_p
|
||||
|
||||
SYNOPSIS
|
||||
bfd_boolean core_file_matches_executable_p
|
||||
(bfd *core_bfd, bfd *exec_bfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return <<TRUE>> if the core file attached to @var{core_bfd}
|
||||
was generated by a run of the executable file attached to
|
||||
@var{exec_bfd}, <<FALSE>> otherwise.
|
||||
*/
|
||||
|
||||
bfd_boolean
|
||||
core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
|
||||
{
|
||||
if (core_bfd->format != bfd_core || exec_bfd->format != bfd_object)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return BFD_SEND (core_bfd, _core_file_matches_executable_p,
|
||||
(core_bfd, exec_bfd));
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/* BFD support for the AMD 29000 architecture.
|
||||
Copyright 1992, 2000, 2002 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type bfd_a29k_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_a29k,
|
||||
0, /* only 1 machine */
|
||||
"a29k",
|
||||
"a29k",
|
||||
4,
|
||||
TRUE, /* the one and only */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
||||
@@ -1,51 +0,0 @@
|
||||
/* BFD support for the Alpha architecture.
|
||||
Copyright 1992, 1993, 1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \
|
||||
{ \
|
||||
BITS_WORD, /* bits in a word */ \
|
||||
BITS_ADDR, /* bits in an address */ \
|
||||
8, /* 8 bits in a byte */ \
|
||||
bfd_arch_alpha, \
|
||||
NUMBER, \
|
||||
"alpha", \
|
||||
PRINT, \
|
||||
3, \
|
||||
DEFAULT, \
|
||||
bfd_default_compatible, \
|
||||
bfd_default_scan, \
|
||||
NEXT, \
|
||||
}
|
||||
|
||||
#define NN(index) (&arch_info_struct[index])
|
||||
|
||||
/* These exist only so that we can reasonably disassemble PALcode. */
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
N (64, 64, bfd_mach_alpha_ev4, "alpha:ev4", FALSE, NN(1)),
|
||||
N (64, 64, bfd_mach_alpha_ev5, "alpha:ev5", FALSE, NN(2)),
|
||||
N (64, 64, bfd_mach_alpha_ev6, "alpha:ev6", FALSE, 0),
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_alpha_arch =
|
||||
N (64, 64, 0, "alpha", TRUE, NN(0));
|
||||
@@ -1,70 +0,0 @@
|
||||
/* BFD support for the ARC processor
|
||||
Copyright 1994, 1995, 1997, 2001, 2002 Free Software Foundation, Inc.
|
||||
Contributed by Doug Evans (dje@cygnus.com).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#define ARC(mach, print_name, default_p, next) \
|
||||
{ \
|
||||
32, /* 32 bits in a word */ \
|
||||
32, /* 32 bits in an address */ \
|
||||
8, /* 8 bits in a byte */ \
|
||||
bfd_arch_arc, \
|
||||
mach, \
|
||||
"arc", \
|
||||
print_name, \
|
||||
4, /* section alignment power */ \
|
||||
default_p, \
|
||||
bfd_default_compatible, \
|
||||
bfd_default_scan, \
|
||||
next, \
|
||||
}
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
ARC ( bfd_mach_arc_5, "arc5", FALSE, &arch_info_struct[1] ),
|
||||
ARC ( bfd_mach_arc_5, "base", FALSE, &arch_info_struct[2] ),
|
||||
ARC ( bfd_mach_arc_6, "arc6", FALSE, &arch_info_struct[3] ),
|
||||
ARC ( bfd_mach_arc_7, "arc7", FALSE, &arch_info_struct[4] ),
|
||||
ARC ( bfd_mach_arc_8, "arc8", FALSE, NULL ),
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_arc_arch =
|
||||
ARC ( bfd_mach_arc_6, "arc", TRUE, &arch_info_struct[0] );
|
||||
|
||||
/* Utility routines. */
|
||||
|
||||
/* Given cpu type NAME, return its bfd_mach_arc_xxx value.
|
||||
Returns -1 if not found. */
|
||||
|
||||
int arc_get_mach PARAMS ((char *));
|
||||
|
||||
int
|
||||
arc_get_mach (name)
|
||||
char *name;
|
||||
{
|
||||
const bfd_arch_info_type *p;
|
||||
|
||||
for (p = &bfd_arc_arch; p != NULL; p = p->next)
|
||||
if (strcmp (name, p->printable_name) == 0)
|
||||
return p->mach;
|
||||
return -1;
|
||||
}
|
||||
418
bfd/cpu-arm.c
418
bfd/cpu-arm.c
@@ -1,418 +0,0 @@
|
||||
/* BFD support for the ARM processor
|
||||
Copyright 1994, 1997, 1999, 2000, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
static const bfd_arch_info_type * compatible
|
||||
PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
|
||||
static bfd_boolean scan
|
||||
PARAMS ((const struct bfd_arch_info *, const char *));
|
||||
static bfd_boolean arm_check_note
|
||||
PARAMS ((bfd *, char *, bfd_size_type, const char *, char **));
|
||||
|
||||
/* This routine is provided two arch_infos and works out which ARM
|
||||
machine which would be compatible with both and returns a pointer
|
||||
to its info structure. */
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
compatible (a,b)
|
||||
const bfd_arch_info_type * a;
|
||||
const bfd_arch_info_type * b;
|
||||
{
|
||||
/* If a & b are for different architecture we can do nothing. */
|
||||
if (a->arch != b->arch)
|
||||
return NULL;
|
||||
|
||||
/* If a & b are for the same machine then all is well. */
|
||||
if (a->mach == b->mach)
|
||||
return a;
|
||||
|
||||
/* Otherwise if either a or b is the 'default' machine
|
||||
then it can be polymorphed into the other. */
|
||||
if (a->the_default)
|
||||
return b;
|
||||
|
||||
if (b->the_default)
|
||||
return a;
|
||||
|
||||
/* So far all newer ARM architecture cores are
|
||||
supersets of previous cores. */
|
||||
if (a->mach < b->mach)
|
||||
return b;
|
||||
else if (a->mach > b->mach)
|
||||
return a;
|
||||
|
||||
/* Never reached! */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct
|
||||
{
|
||||
unsigned int mach;
|
||||
char * name;
|
||||
}
|
||||
processors[] =
|
||||
{
|
||||
{ bfd_mach_arm_2, "arm2" },
|
||||
{ bfd_mach_arm_2a, "arm250" },
|
||||
{ bfd_mach_arm_2a, "arm3" },
|
||||
{ bfd_mach_arm_3, "arm6" },
|
||||
{ bfd_mach_arm_3, "arm60" },
|
||||
{ bfd_mach_arm_3, "arm600" },
|
||||
{ bfd_mach_arm_3, "arm610" },
|
||||
{ bfd_mach_arm_3, "arm7" },
|
||||
{ bfd_mach_arm_3, "arm710" },
|
||||
{ bfd_mach_arm_3, "arm7500" },
|
||||
{ bfd_mach_arm_3, "arm7d" },
|
||||
{ bfd_mach_arm_3, "arm7di" },
|
||||
{ bfd_mach_arm_3M, "arm7dm" },
|
||||
{ bfd_mach_arm_3M, "arm7dmi" },
|
||||
{ bfd_mach_arm_4T, "arm7tdmi" },
|
||||
{ bfd_mach_arm_4, "arm8" },
|
||||
{ bfd_mach_arm_4, "arm810" },
|
||||
{ bfd_mach_arm_4, "arm9" },
|
||||
{ bfd_mach_arm_4, "arm920" },
|
||||
{ bfd_mach_arm_4T, "arm920t" },
|
||||
{ bfd_mach_arm_4T, "arm9tdmi" },
|
||||
{ bfd_mach_arm_4, "sa1" },
|
||||
{ bfd_mach_arm_4, "strongarm"},
|
||||
{ bfd_mach_arm_4, "strongarm110" },
|
||||
{ bfd_mach_arm_4, "strongarm1100" },
|
||||
{ bfd_mach_arm_XScale, "xscale" },
|
||||
{ bfd_mach_arm_ep9312, "ep9312" },
|
||||
{ bfd_mach_arm_iWMMXt, "iwmmxt" }
|
||||
};
|
||||
|
||||
static bfd_boolean
|
||||
scan (info, string)
|
||||
const struct bfd_arch_info * info;
|
||||
const char * string;
|
||||
{
|
||||
int i;
|
||||
|
||||
/* First test for an exact match. */
|
||||
if (strcasecmp (string, info->printable_name) == 0)
|
||||
return TRUE;
|
||||
|
||||
/* Next check for a processor name instead of an Architecture name. */
|
||||
for (i = sizeof (processors) / sizeof (processors[0]); i--;)
|
||||
{
|
||||
if (strcasecmp (string, processors [i].name) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i != -1 && info->mach == processors [i].mach)
|
||||
return TRUE;
|
||||
|
||||
/* Finally check for the default architecture. */
|
||||
if (strcasecmp (string, "arm") == 0)
|
||||
return info->the_default;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define N(number, print, default, next) \
|
||||
{ 32, 32, 8, bfd_arch_arm, number, "arm", print, 4, default, compatible, scan, next }
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
N (bfd_mach_arm_2, "armv2", FALSE, & arch_info_struct[1]),
|
||||
N (bfd_mach_arm_2a, "armv2a", FALSE, & arch_info_struct[2]),
|
||||
N (bfd_mach_arm_3, "armv3", FALSE, & arch_info_struct[3]),
|
||||
N (bfd_mach_arm_3M, "armv3m", FALSE, & arch_info_struct[4]),
|
||||
N (bfd_mach_arm_4, "armv4", FALSE, & arch_info_struct[5]),
|
||||
N (bfd_mach_arm_4T, "armv4t", FALSE, & arch_info_struct[6]),
|
||||
N (bfd_mach_arm_5, "armv5", FALSE, & arch_info_struct[7]),
|
||||
N (bfd_mach_arm_5T, "armv5t", FALSE, & arch_info_struct[8]),
|
||||
N (bfd_mach_arm_5TE, "armv5te", FALSE, & arch_info_struct[9]),
|
||||
N (bfd_mach_arm_XScale, "xscale", FALSE, & arch_info_struct[10]),
|
||||
N (bfd_mach_arm_ep9312, "ep9312", FALSE, & arch_info_struct[11]),
|
||||
N (bfd_mach_arm_iWMMXt,"iwmmxt", FALSE, NULL)
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_arm_arch =
|
||||
N (0, "arm", TRUE, & arch_info_struct[0]);
|
||||
|
||||
/* Support functions used by both the COFF and ELF versions of the ARM port. */
|
||||
|
||||
/* Handle the merging of the 'machine' settings of input file IBFD
|
||||
and an output file OBFD. These values actually represent the
|
||||
different possible ARM architecture variants.
|
||||
Returns TRUE if they were merged successfully or FALSE otherwise. */
|
||||
|
||||
bfd_boolean
|
||||
bfd_arm_merge_machines (ibfd, obfd)
|
||||
bfd * ibfd;
|
||||
bfd * obfd;
|
||||
{
|
||||
unsigned int in = bfd_get_mach (ibfd);
|
||||
unsigned int out = bfd_get_mach (obfd);
|
||||
|
||||
/* If the output architecture is unknown, we now have a value to set. */
|
||||
if (out == bfd_mach_arm_unknown)
|
||||
bfd_set_arch_mach (obfd, bfd_arch_arm, in);
|
||||
|
||||
/* If the input architecture is unknown,
|
||||
then so must be the output architecture. */
|
||||
else if (in == bfd_mach_arm_unknown)
|
||||
/* FIXME: We ought to have some way to
|
||||
override this on the command line. */
|
||||
bfd_set_arch_mach (obfd, bfd_arch_arm, bfd_mach_arm_unknown);
|
||||
|
||||
/* If they are the same then nothing needs to be done. */
|
||||
else if (out == in)
|
||||
;
|
||||
|
||||
/* Otherwise the general principle that a earlier architecture can be
|
||||
linked with a later architecture to produce a binary that will execute
|
||||
on the later architecture.
|
||||
|
||||
We fail however if we attempt to link a Cirrus EP9312 binary with an
|
||||
Intel XScale binary, since these architecture have co-processors which
|
||||
will not both be present on the same physical hardware. */
|
||||
else if (in == bfd_mach_arm_ep9312
|
||||
&& (out == bfd_mach_arm_XScale || out == bfd_mach_arm_iWMMXt))
|
||||
{
|
||||
_bfd_error_handler (_("\
|
||||
ERROR: %B is compiled for the EP9312, whereas %B is compiled for XScale"),
|
||||
ibfd, obfd);
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return FALSE;
|
||||
}
|
||||
else if (out == bfd_mach_arm_ep9312
|
||||
&& (in == bfd_mach_arm_XScale || in == bfd_mach_arm_iWMMXt))
|
||||
{
|
||||
_bfd_error_handler (_("\
|
||||
ERROR: %B is compiled for the EP9312, whereas %B is compiled for XScale"),
|
||||
obfd, ibfd);
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return FALSE;
|
||||
}
|
||||
else if (in > out)
|
||||
bfd_set_arch_mach (obfd, bfd_arch_arm, in);
|
||||
/* else
|
||||
Nothing to do. */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char namesz[4]; /* Size of entry's owner string. */
|
||||
unsigned char descsz[4]; /* Size of the note descriptor. */
|
||||
unsigned char type[4]; /* Interpretation of the descriptor. */
|
||||
char name[1]; /* Start of the name+desc data. */
|
||||
} arm_Note;
|
||||
|
||||
static bfd_boolean
|
||||
arm_check_note (abfd, buffer, buffer_size, expected_name, description_return)
|
||||
bfd * abfd;
|
||||
char * buffer;
|
||||
bfd_size_type buffer_size;
|
||||
const char * expected_name;
|
||||
char ** description_return;
|
||||
{
|
||||
unsigned long namesz;
|
||||
unsigned long descsz;
|
||||
unsigned long type;
|
||||
char * descr;
|
||||
|
||||
if (buffer_size < offsetof (arm_Note, name))
|
||||
return FALSE;
|
||||
|
||||
/* We have to extract the values this way to allow for a
|
||||
host whose endian-ness is different from the target. */
|
||||
namesz = bfd_get_32 (abfd, buffer);
|
||||
descsz = bfd_get_32 (abfd, buffer + offsetof (arm_Note, descsz));
|
||||
type = bfd_get_32 (abfd, buffer + offsetof (arm_Note, type));
|
||||
descr = buffer + offsetof (arm_Note, name);
|
||||
|
||||
/* Check for buffer overflow. */
|
||||
if (namesz + descsz + offsetof (arm_Note, name) > buffer_size)
|
||||
return FALSE;
|
||||
|
||||
if (expected_name == NULL)
|
||||
{
|
||||
if (namesz != 0)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (namesz != ((strlen (expected_name) + 1 + 3) & ~3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (descr, expected_name) != 0)
|
||||
return FALSE;
|
||||
|
||||
descr += (namesz + 3) & ~3;
|
||||
}
|
||||
|
||||
/* FIXME: We should probably check the type as well. */
|
||||
|
||||
if (description_return != NULL)
|
||||
* description_return = descr;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define NOTE_ARCH_STRING "arch: "
|
||||
|
||||
bfd_boolean
|
||||
bfd_arm_update_notes (abfd, note_section)
|
||||
bfd * abfd;
|
||||
const char * note_section;
|
||||
{
|
||||
asection * arm_arch_section;
|
||||
bfd_size_type buffer_size;
|
||||
bfd_byte * buffer;
|
||||
char * arch_string;
|
||||
char * expected;
|
||||
|
||||
/* Look for a note section. If one is present check the architecture
|
||||
string encoded in it, and set it to the current architecture if it is
|
||||
different. */
|
||||
arm_arch_section = bfd_get_section_by_name (abfd, note_section);
|
||||
|
||||
if (arm_arch_section == NULL)
|
||||
return TRUE;
|
||||
|
||||
buffer_size = arm_arch_section->size;
|
||||
if (buffer_size == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!bfd_malloc_and_get_section (abfd, arm_arch_section, &buffer))
|
||||
goto FAIL;
|
||||
|
||||
/* Parse the note. */
|
||||
if (! arm_check_note (abfd, buffer, buffer_size, NOTE_ARCH_STRING, & arch_string))
|
||||
goto FAIL;
|
||||
|
||||
/* Check the architecture in the note against the architecture of the bfd. */
|
||||
switch (bfd_get_mach (abfd))
|
||||
{
|
||||
default:
|
||||
case bfd_mach_arm_unknown: expected = "unknown"; break;
|
||||
case bfd_mach_arm_2: expected = "armv2"; break;
|
||||
case bfd_mach_arm_2a: expected = "armv2a"; break;
|
||||
case bfd_mach_arm_3: expected = "armv3"; break;
|
||||
case bfd_mach_arm_3M: expected = "armv3M"; break;
|
||||
case bfd_mach_arm_4: expected = "armv4"; break;
|
||||
case bfd_mach_arm_4T: expected = "armv4t"; break;
|
||||
case bfd_mach_arm_5: expected = "armv5"; break;
|
||||
case bfd_mach_arm_5T: expected = "armv5t"; break;
|
||||
case bfd_mach_arm_5TE: expected = "armv5te"; break;
|
||||
case bfd_mach_arm_XScale: expected = "XScale"; break;
|
||||
case bfd_mach_arm_ep9312: expected = "ep9312"; break;
|
||||
case bfd_mach_arm_iWMMXt: expected = "iWMMXt"; break;
|
||||
}
|
||||
|
||||
if (strcmp (arch_string, expected) != 0)
|
||||
{
|
||||
strcpy (buffer + offsetof (arm_Note, name) + ((strlen (NOTE_ARCH_STRING) + 3) & ~3), expected);
|
||||
|
||||
if (! bfd_set_section_contents (abfd, arm_arch_section, buffer,
|
||||
(file_ptr) 0, buffer_size))
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("warning: unable to update contents of %s section in %s"),
|
||||
note_section, bfd_get_filename (abfd));
|
||||
goto FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
free (buffer);
|
||||
return TRUE;
|
||||
|
||||
FAIL:
|
||||
if (buffer != NULL)
|
||||
free (buffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static struct
|
||||
{
|
||||
const char * string;
|
||||
unsigned int mach;
|
||||
}
|
||||
architectures[] =
|
||||
{
|
||||
{ "armv2", bfd_mach_arm_2 },
|
||||
{ "armv2a", bfd_mach_arm_2a },
|
||||
{ "armv3", bfd_mach_arm_3 },
|
||||
{ "armv3M", bfd_mach_arm_3M },
|
||||
{ "armv4", bfd_mach_arm_4 },
|
||||
{ "armv4t", bfd_mach_arm_4T },
|
||||
{ "armv5", bfd_mach_arm_5 },
|
||||
{ "armv5t", bfd_mach_arm_5T },
|
||||
{ "armv5te", bfd_mach_arm_5TE },
|
||||
{ "XScale", bfd_mach_arm_XScale },
|
||||
{ "ep9312", bfd_mach_arm_ep9312 },
|
||||
{ "iWMMXt", bfd_mach_arm_iWMMXt }
|
||||
};
|
||||
|
||||
/* Extract the machine number stored in a note section. */
|
||||
unsigned int
|
||||
bfd_arm_get_mach_from_notes (abfd, note_section)
|
||||
bfd * abfd;
|
||||
const char * note_section;
|
||||
{
|
||||
asection * arm_arch_section;
|
||||
bfd_size_type buffer_size;
|
||||
bfd_byte * buffer;
|
||||
char * arch_string;
|
||||
int i;
|
||||
|
||||
/* Look for a note section. If one is present check the architecture
|
||||
string encoded in it, and set it to the current architecture if it is
|
||||
different. */
|
||||
arm_arch_section = bfd_get_section_by_name (abfd, note_section);
|
||||
|
||||
if (arm_arch_section == NULL)
|
||||
return bfd_mach_arm_unknown;
|
||||
|
||||
buffer_size = arm_arch_section->size;
|
||||
if (buffer_size == 0)
|
||||
return bfd_mach_arm_unknown;
|
||||
|
||||
if (!bfd_malloc_and_get_section (abfd, arm_arch_section, &buffer))
|
||||
goto FAIL;
|
||||
|
||||
/* Parse the note. */
|
||||
if (! arm_check_note (abfd, buffer, buffer_size, NOTE_ARCH_STRING, & arch_string))
|
||||
goto FAIL;
|
||||
|
||||
/* Interpret the architecture string. */
|
||||
for (i = ARRAY_SIZE (architectures); i--;)
|
||||
if (strcmp (arch_string, architectures[i].string) == 0)
|
||||
{
|
||||
free (buffer);
|
||||
return architectures[i].mach;
|
||||
}
|
||||
|
||||
FAIL:
|
||||
if (buffer != NULL)
|
||||
free (buffer);
|
||||
return bfd_mach_arm_unknown;
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/* BFD library support routines for the AVR architecture.
|
||||
Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
|
||||
Contributed by Denis Chertykov <denisc@overta.ru>
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
static const bfd_arch_info_type *compatible
|
||||
PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
|
||||
|
||||
#define N(addr_bits, machine, print, default, next) \
|
||||
{ \
|
||||
8, /* 8 bits in a word */ \
|
||||
addr_bits, /* bits in an address */ \
|
||||
8, /* 8 bits in a byte */ \
|
||||
bfd_arch_avr, \
|
||||
machine, /* machine */ \
|
||||
"avr", /* arch_name */ \
|
||||
print, /* printable name */ \
|
||||
1, /* section align power */ \
|
||||
default, /* the default machine */ \
|
||||
compatible, \
|
||||
bfd_default_scan, \
|
||||
next \
|
||||
}
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
/* AT90S1200, ATtiny1x, ATtiny28 */
|
||||
N (16, bfd_mach_avr1, "avr:1", FALSE, & arch_info_struct[1]),
|
||||
|
||||
/* AT90S2xxx, AT90S4xxx, AT90S8xxx, ATtiny22 */
|
||||
N (16, bfd_mach_avr2, "avr:2", FALSE, & arch_info_struct[2]),
|
||||
|
||||
/* ATmega103, ATmega603 */
|
||||
N (22, bfd_mach_avr3, "avr:3", FALSE, & arch_info_struct[3]),
|
||||
|
||||
/* ATmega83, ATmega85 */
|
||||
N (16, bfd_mach_avr4, "avr:4", FALSE, & arch_info_struct[4]),
|
||||
|
||||
/* ATmega161, ATmega163, ATmega32, AT94K */
|
||||
N (22, bfd_mach_avr5, "avr:5", FALSE, NULL)
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_avr_arch =
|
||||
N (16, bfd_mach_avr2, "avr", TRUE, & arch_info_struct[0]);
|
||||
|
||||
/* This routine is provided two arch_infos and works out which AVR
|
||||
machine which would be compatible with both and returns a pointer
|
||||
to its info structure. */
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
compatible (a,b)
|
||||
const bfd_arch_info_type * a;
|
||||
const bfd_arch_info_type * b;
|
||||
{
|
||||
/* If a & b are for different architectures we can do nothing. */
|
||||
if (a->arch != b->arch)
|
||||
return NULL;
|
||||
|
||||
/* Special case for ATmega[16]03 (avr:3) and ATmega83 (avr:4). */
|
||||
if ((a->mach == bfd_mach_avr3 && b->mach == bfd_mach_avr4)
|
||||
|| (a->mach == bfd_mach_avr4 && b->mach == bfd_mach_avr3))
|
||||
return NULL;
|
||||
|
||||
/* So far all newer AVR architecture cores are supersets of previous
|
||||
cores. */
|
||||
if (a->mach <= b->mach)
|
||||
return b;
|
||||
|
||||
if (a->mach >= b->mach)
|
||||
return a;
|
||||
|
||||
/* Never reached! */
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/* BFD support for the CR16C processor.
|
||||
Copyright 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type bfd_cr16c_arch =
|
||||
{
|
||||
16, /* 16 bits in a word. */
|
||||
32, /* 32 bits in an address. */
|
||||
8, /* 8 bits in a byte. */
|
||||
bfd_arch_cr16c,
|
||||
bfd_mach_cr16c,
|
||||
"cr16c",
|
||||
"cr16c",
|
||||
1,
|
||||
TRUE, /* The one and only. */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
||||
@@ -1,57 +0,0 @@
|
||||
/* BFD support for the Axis CRIS architecture.
|
||||
Copyright 2000, 2002 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type
|
||||
bfd_cris_arch =
|
||||
{
|
||||
32, /* There's 32 bits_per_word. */
|
||||
32, /* There's 32 bits_per_address. */
|
||||
8, /* There's 8 bits_per_byte. */
|
||||
bfd_arch_cris, /* One of enum bfd_architecture, defined
|
||||
in archures.c and provided in
|
||||
generated header files. */
|
||||
0xff, /* Only 1 machine, but #255 for
|
||||
historical reasons. */
|
||||
"cris", /* The arch_name. */
|
||||
"cris", /* The printable name is the same. */
|
||||
1, /* Section alignment power; each section
|
||||
is aligned to (only) 2^1 bytes. */
|
||||
TRUE, /* This is the default "machine", since
|
||||
there's only one. */
|
||||
bfd_default_compatible, /* A default function for testing
|
||||
"machine" compatibility of two
|
||||
bfd_arch_info_type. */
|
||||
bfd_default_scan, /* Check if a bfd_arch_info_type is a
|
||||
match. */
|
||||
NULL /* Pointer to next bfd_arch_info_type in
|
||||
the same family. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,39 +0,0 @@
|
||||
/* BFD support for the CRX processor.
|
||||
Copyright 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
const bfd_arch_info_type bfd_crx_arch =
|
||||
{
|
||||
16, /* 16 bits in a word. */
|
||||
32, /* 32 bits in an address. */
|
||||
8, /* 8 bits in a byte. */
|
||||
bfd_arch_crx, /* enum bfd_architecture arch. */
|
||||
bfd_mach_crx,
|
||||
"crx", /* Arch name. */
|
||||
"crx", /* Printable name. */
|
||||
1, /* Unsigned int section alignment power. */
|
||||
TRUE, /* The one and only. */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user